-
Notifications
You must be signed in to change notification settings - Fork 0
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: add antlr grammar for testcase file #2
base: main
Are you sure you want to change the base?
Conversation
ACTION NEEDED Substrait follows the Conventional Commits The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
grammar/SubstraitType.g4
Outdated
| PrecisionTimestamp isnull=QMark? Lt precision=numericParameter Gt #precisionTimestamp | ||
| PrecisionTimestampTZ isnull=QMark? Lt precision=numericParameter Gt #precisionTimestampTZ | ||
| Struct isnull=QMark? Lt expr (Comma expr)* Gt #struct | ||
| NStruct isnull=QMark? Lt Identifier expr (Comma Identifier expr)* Gt #nStruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see Nstruct in type.proto (here). Where it is coming from ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar/SubstraitType.g4
Outdated
| Decimal isnull=QMark? Lt precision=numericParameter Comma scale=numericParameter Gt #decimal | ||
| PrecisionTimestamp isnull=QMark? Lt precision=numericParameter Gt #precisionTimestamp | ||
| PrecisionTimestampTZ isnull=QMark? Lt precision=numericParameter Gt #precisionTimestampTZ | ||
| Struct isnull=QMark? Lt expr (Comma expr)* Gt #struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't struct take type. In proto file it takes type (here)
| Struct isnull=QMark? Lt expr (Comma expr)* Gt #struct | |
| Struct isnull=QMark? Lt type (Comma type)* Gt #struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expr
is type expression
grammar/SubstraitType.g4
Outdated
| PrecisionTimestampTZ isnull=QMark? Lt precision=numericParameter Gt #precisionTimestampTZ | ||
| Struct isnull=QMark? Lt expr (Comma expr)* Gt #struct | ||
| NStruct isnull=QMark? Lt Identifier expr (Comma Identifier expr)* Gt #nStruct | ||
| List isnull=QMark? Lt expr Gt #list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as struct. Proto file mentions type (here)
| List isnull=QMark? Lt expr Gt #list | |
| List isnull=QMark? Lt type Gt #list |
grammar/SubstraitType.g4
Outdated
| Struct isnull=QMark? Lt expr (Comma expr)* Gt #struct | ||
| NStruct isnull=QMark? Lt Identifier expr (Comma Identifier expr)* Gt #nStruct | ||
| List isnull=QMark? Lt expr Gt #list | ||
| Map isnull=QMark? Lt key=expr Comma value=expr Gt #map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as struct. Proto file mentions type (here)
| Map isnull=QMark? Lt key=expr Comma value=expr Gt #map | |
| Map isnull=QMark? Lt key=type Comma value=type Gt #map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed it fully. I am still halfway
@@ -0,0 +1,330 @@ | |||
token literal names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how others feel but seeing file names that are Test* makes me think they are test files as opposed to files that are responsible parsing a test file format. Maybe some other naming pattern could make that clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about FuncTestSpec
as prefix?
This file will become FuncTestSpecLexer
tests/coverage/extensions.py
Outdated
"i8": "i8", | ||
"i16": "i16", | ||
"i32": "i32", | ||
"i64": "i64", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way we can push these patterns into the parser for use across tools? I think we need them to go from in grammar literal to types. Let's just do that with the grammar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a change to use rule names, and added a test to assert to ensure names do not change. Grammar is not using simple literals for type names to allow case-insensitive names.
short_type_to_type = {st: lt for lt, st in type_to_short_type.items()} | ||
|
||
|
||
class Extension: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't clear why we need this stuff. seems like the grammar could handle and move us straight to appropriate objects in many (most?) cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to build function registry from extensions which will be used to compute test coverage for each function variant.
@@ -0,0 +1,12 @@ | |||
# SPDX-License-Identifier: Apache-2.0 | |||
def test_read_substrait_extensions(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add to github precommit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Coverage tool output