Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: misc fixes and cleanup to func testcase grammar #742

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 41 additions & 36 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 All @@ -212,7 +219,6 @@ scalarType
| timestampTZType #timestampTz
| Date #date
| Time #time
| intervalDayType #intervalDay
| intervalYearType #intervalYear
| UUID #uuid
| UserDefined Identifier #userDefined
Expand Down Expand Up @@ -243,34 +249,32 @@ intervalYearType
;

intervalDayType
: (IDay | Interval_Day)
: (IDay | Interval_Day) isnull=QMark? (OAngleBracket len=numericParameter CAngleBracket)?
;

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 All @@ -282,6 +286,7 @@ parameterizedType
| varCharType
| fixedBinaryType
| decimalType
| intervalDayType
| precisionTimestampType
| precisionTimestampTZType
// TODO implement the rest of the parameterized types
Expand All @@ -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
EpsilonPrime marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading