Skip to content

Commit

Permalink
feat: misc fixes and cleanup to func testcase grammar
Browse files Browse the repository at this point in the history
 - to support missing
 - to support zero argument aggregate function
  • Loading branch information
scgkiran committed Nov 14, 2024
1 parent d4998a7 commit 50dcfed
Show file tree
Hide file tree
Showing 9 changed files with 2,459 additions and 2,724 deletions.
73 changes: 39 additions & 34 deletions grammar/FuncTestCaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ testGroupDescription
;

testCase
: functionName=identifier OParen arguments CParen ( OBracket func_options CBracket )? Eq result
: functionName=identifier OParen arguments CParen ( OBracket funcOptions CBracket )? Eq result
;

testGroup
Expand Down Expand Up @@ -57,16 +57,21 @@ argument
| timestampTzArg
| intervalYearArg
| intervalDayArg
| fixedCharArg
| varCharArg
| fixedBinaryArg
| precisionTimestampArg
| precisionTimestampTZArg
| listArg
;

aggFuncTestCase
: aggFuncCall ( OBracket func_options CBracket )? Eq result
: aggFuncCall ( OBracket funcOptions CBracket )? Eq result
;

aggFuncCall
: tableData funcName=identifier OParen qualifiedAggregateFuncArgs CParen #multiArgAggregateFuncCall
| tableRows functName=identifier OParen aggregateFuncArgs CParen #compactAggregateFuncCall
: tableData funcName=identifier OParen qualifiedAggregateFuncArgs? CParen #multiArgAggregateFuncCall
| tableRows functName=identifier OParen aggregateFuncArgs? CParen #compactAggregateFuncCall
| functName=identifier OParen dataColumn CParen #singleArgAggregateFuncCall
;

Expand Down Expand Up @@ -167,30 +172,32 @@ intervalDayArg
: IntervalDayLiteral DoubleColon intervalDayType
;

listArg
: literalList DoubleColon listType
fixedCharArg
: StringLiteral DoubleColon fixedCharType
;

literalList
: OBracket (literal (Comma literal)*)? CBracket
varCharArg
: StringLiteral DoubleColon varCharType
;

fixedBinaryArg
: StringLiteral DoubleColon fixedBinaryType
;

intervalYearLiteral
: PeriodPrefix (years=IntegerLiteral YearPrefix) (months=IntegerLiteral MSuffix)?
| PeriodPrefix (months=IntegerLiteral MSuffix)
precisionTimestampArg
: TimestampLiteral DoubleColon precisionTimestampType
;

intervalDayLiteral
: PeriodPrefix (days=IntegerLiteral DaySuffix) (TimePrefix timeInterval)?
| PeriodPrefix TimePrefix timeInterval
precisionTimestampTZArg
: TimestampTzLiteral DoubleColon precisionTimestampTZType
;

timeInterval
: hours=IntegerLiteral HourSuffix (minutes=IntegerLiteral MSuffix)? (seconds=IntegerLiteral SecondSuffix)?
(fractionalSeconds=IntegerLiteral FractionalSecondSuffix)?
| minutes=IntegerLiteral MSuffix (seconds=IntegerLiteral SecondSuffix)? (fractionalSeconds=IntegerLiteral FractionalSecondSuffix)?
| seconds=IntegerLiteral SecondSuffix (fractionalSeconds=IntegerLiteral FractionalSecondSuffix)?
| fractionalSeconds=IntegerLiteral FractionalSecondSuffix
listArg
: literalList DoubleColon listType
;

literalList
: OBracket (literal (Comma literal)*)? CBracket
;

dataType
Expand Down Expand Up @@ -247,30 +254,28 @@ intervalDayType
;

fixedCharType
: (FChar | FixedChar) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket #fixedChar
: (FChar | FixedChar) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket
;

varCharType
: (VChar | VarChar) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket #varChar
: (VChar | VarChar) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket
;

fixedBinaryType
: (FBin | FixedBinary) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket #fixedBinary
: (FBin | FixedBinary) isnull=QMark? OAngleBracket len=numericParameter CAngleBracket
;

decimalType
: (Dec | Decimal) isnull=QMark?
(OAngleBracket precision=numericParameter Comma scale=numericParameter CAngleBracket)? #decimal
(OAngleBracket precision=numericParameter Comma scale=numericParameter CAngleBracket)?
;

precisionTimestampType
: (PTs | Precision_Timestamp) isnull=QMark?
OAngleBracket precision=numericParameter CAngleBracket #precisionTimestamp
: (PTs | Precision_Timestamp) isnull=QMark? OAngleBracket precision=numericParameter CAngleBracket
;

precisionTimestampTZType
: (PTsTZ | Precision_Timestamp_TZ) isnull=QMark?
OAngleBracket precision=numericParameter CAngleBracket #precisionTimestampTZ
: (PTsTZ | Precision_Timestamp_TZ) isnull=QMark? OAngleBracket precision=numericParameter CAngleBracket
;

listType
Expand Down Expand Up @@ -298,24 +303,24 @@ substraitError
: ErrorResult | UndefineResult
;

func_option
: option_name Colon option_value
funcOption
: optionName Colon optionValue
;

option_name
optionName
: Overflow | Rounding | NullHandling | SpacesOnly
| Identifier
;

option_value
optionValue
: Error | Saturate | Silent | TieToEven | NaN | Truncate | AcceptNulls | IgnoreNulls
| BooleanLiteral
| NullLiteral
| Identifier
;

func_options
: func_option (Comma func_option)*
funcOptions
: funcOption (Comma funcOption)*
;

nonReserved // IMPORTANT: this rule must only contain tokens
Expand Down
1 change: 1 addition & 0 deletions grammar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ generate_type_parser:
clean:
rm -rf $(TYPE_OUTPUT_DIR)/*.py $(TYPE_OUTPUT_DIR)/*.tokens $(TYPE_OUTPUT_DIR)/*.interp
rm -rf $(TESTCASE_OUTPUT_DIR)/*.py $(TESTCASE_OUTPUT_DIR)/*.tokens $(TESTCASE_OUTPUT_DIR)/*.interp
rm -rf ./*.tokens
Loading

0 comments on commit 50dcfed

Please sign in to comment.