Skip to content

feat: add Phase 4 function extensions (DateTime, Context)#38

Merged
sivchari merged 3 commits intomainfrom
feat/phase4-functions
Feb 13, 2026
Merged

feat: add Phase 4 function extensions (DateTime, Context)#38
sivchari merged 3 commits intomainfrom
feat/phase4-functions

Conversation

@sivchari
Copy link
Copy Markdown
Owner

Summary

  • Add US date format support (MM/DD/YYYY, MM-DD-YYYY) to TO_DATE function
  • Implement context functions: CURRENT_USER, CURRENT_DATABASE, CURRENT_SCHEMA, CURRENT_ROLE, CURRENT_WAREHOUSE
  • Fix TestWindowFirstLastValue to use subquery for correct window function behavior

Changes

TO_DATE Function Enhancement

  • Support for US date formats: MM/DD/YYYY and MM-DD-YYYY

Context Functions Implementation

Function Returns
CURRENT_USER() "EMULATOR_USER" (fixed)
CURRENT_ROLE() "ACCOUNTADMIN" (fixed)
CURRENT_WAREHOUSE() "EMULATOR_WH" (fixed)
CURRENT_DATABASE() Session state (via USE DATABASE)
CURRENT_SCHEMA() Session state (via USE SCHEMA)

SQL Rewriter

  • Convert CURRENT_USER()current_user (DataFusion keyword syntax)
  • Convert CURRENT_DATABASE()current_database
  • Convert CURRENT_SCHEMA()current_schema

Test plan

  • All Go integration tests pass
  • TestToDate passes with US format
  • TestCurrentUser, TestCurrentDatabase pass
  • TestWindowFirstLastValue passes with subquery fix

Add support for MM/DD/YYYY and MM-DD-YYYY date formats to the TO_DATE
function to handle US-style date strings. This enables compatibility
with common American date formatting conventions.
Implement support for Snowflake context functions:
- CURRENT_USER() returns "EMULATOR_USER" (fixed value)
- CURRENT_ROLE() returns "ACCOUNTADMIN" (fixed value)
- CURRENT_WAREHOUSE() returns "EMULATOR_WH" (fixed value)
- CURRENT_DATABASE() returns session state (changeable via USE DATABASE)
- CURRENT_SCHEMA() returns session state (changeable via USE SCHEMA)

SQL rewriter converts Snowflake syntax CURRENT_USER() to DataFusion-compatible
current_user (no parentheses), as DataFusion treats these as keywords.

Changed default database from "TESTDB" to "EMULATOR_DB" for consistency.
- Remove t.Skip from TestToDate (US format now supported)
- Remove t.Skip from TestCurrentUser (CURRENT_USER now implemented)
- Remove t.Skip from TestCurrentDatabase (CURRENT_DATABASE now implemented)
- Remove t.Skip from TestWindowFirstLastValue and fix query to use subquery

TestWindowFirstLastValue fix: Use subquery to ensure window function
calculates over the full partition before WHERE clause filters results.
This corrects the expected behavior where FIRST_VALUE should return 10
(first value in partition 'A') even when filtering to id=2.
@sivchari sivchari merged commit 0298dbf into main Feb 13, 2026
5 checks passed
@sivchari sivchari deleted the feat/phase4-functions branch February 13, 2026 02:36
@github-actions github-actions bot mentioned this pull request Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant