Support Snowflake MATCH_RECOGNIZE syntax#1222
Conversation
Pull Request Test Coverage Report for Build 8773731659Details
💛 - Coveralls |
2e139b6 to
ab21e20
Compare
| } | ||
| } | ||
|
|
||
| if self.dialect.supports_match_recognize() |
There was a problem hiding this comment.
should this use the dialect_of check instead or is the trait method required for this feature?
There was a problem hiding this comment.
I prefer to use the trait method here because it can be reused in the test with all_dialects_where(|d| d.supports_match_recognize(). This way if it's added for another dialect in the future (e.g. Trino), those tests will run without having to remember to add the new dialect to them.
There was a problem hiding this comment.
Ah I see, not sure if we have a guideline for this but feels to me like the dialect trait could get bloated quickly otherwise. Not sure though, deferring to @alamb if you have thoughts (and the PR looks good to me for a review too!)
There was a problem hiding this comment.
Yeah that's a good point. We could do something like this:
struct FeatureSupport {
match_recognize: bool,
// other features
}
trait Dialect {
fn features() -> &'static FeatureSupport;
// methods requiring custom code
}
If FeatureSupport gets too big, we can make it hierarchical.
There was a problem hiding this comment.
I don't have a great story for this question -- it seems to me that the crate is currently inconsistent where sometimes it uses a trait method and sometimes uses the hard coded IsDialect ..
I think the FeatureSupport idea is neat, and if we didn't already have 2 patterns it would probably be the way to go. However, given we already have 2 methods, I think adding a third would be less than ideal
Ideally we would have a single way and I think the best thing for users of the crate is methods on Dialect (mostly so they can define their own custom dialects, which I have seen some of them do). However, I fully acknowledge that the trait will get very large for sure.
However, a wholesale refactoring of the crate is probably not feasible at this time.
If we can get some consensus between the three of us maybe I can add something to the documentation on the preferred method (dialectof or trait method)
There was a problem hiding this comment.
The FeatureSupport proposal seems like it balances the tradeoffs closely but yeah, agree that its likely not ideal to introduce another mechanism for this. At least the Dialect trait methods route sounds very reasonable to me as a preferred method in that case since as mentioned it helps users with custom dialect setup and it makes it easier to add test coverage for dialects.
MATCH_RECOGNIZEMATCH_RECOGNIZE syntax
| } | ||
| } | ||
|
|
||
| if self.dialect.supports_match_recognize() |
There was a problem hiding this comment.
I don't have a great story for this question -- it seems to me that the crate is currently inconsistent where sometimes it uses a trait method and sometimes uses the hard coded IsDialect ..
I think the FeatureSupport idea is neat, and if we didn't already have 2 patterns it would probably be the way to go. However, given we already have 2 methods, I think adding a third would be less than ideal
Ideally we would have a single way and I think the best thing for users of the crate is methods on Dialect (mostly so they can define their own custom dialects, which I have seen some of them do). However, I fully acknowledge that the trait will get very large for sure.
However, a wholesale refactoring of the crate is probably not feasible at this time.
If we can get some consensus between the three of us maybe I can add something to the documentation on the preferred method (dialectof or trait method)
| ), | ||
| ); | ||
|
|
||
| // the grand finale (example taken from snowflake docs) |
|
@jmhain -- this PR looks like it has some conflicts -- would it be possible to resolve them? |
|
@alamb Yep! Done |
|
Thanks @jmhain |
No description provided.