chore: fix spark ansi sum incompatibility message#4111
chore: fix spark ansi sum incompatibility message#4111coderfender wants to merge 3 commits intoapache:mainfrom
Conversation
| case Literal(count, _) if isNegativeNumber(count) => | ||
| withInfo(expr, "Negative repeat count is not supported") | ||
| return None | ||
| case _ => |
There was a problem hiding this comment.
This will guard against negative repeat character but still goes through for positive counts with an error message . getIncompatibleReasons() is to add the right error message on documentation
| Incompatible(None) | ||
| } else { | ||
| Unsupported(None) | ||
| } |
There was a problem hiding this comment.
I tried to leverage the right reason to fallback based on the pattern here
0d481f4 to
2fdb835
Compare
| object CometSum extends CometAggregateExpressionSerde[Sum] { | ||
|
|
||
| override def getIncompatibleReasons(): Seq[String] = Seq("Falls back to Spark in ANSI mode.") | ||
|
|
There was a problem hiding this comment.
we support ansi mode so no need to fallback to spark
| case i: Int => i < 0 | ||
| case l: Long => l < 0 | ||
| case _ => false | ||
| } |
There was a problem hiding this comment.
added this method to be utilized later but can remove it if it is not needed
| val defaultPattern = TimestampFormatter.defaultPattern | ||
| if (formatStr == defaultPattern) { | ||
| Incompatible(None) | ||
| } else { |
There was a problem hiding this comment.
fallback based on specific pattern
|
|
||
| query expect_fallback(not fully compatible with Spark) | ||
| query expect_fallback(Datetime pattern format: yyyy-MM-dd is unsupported) | ||
| SELECT from_unixtime(t, 'yyyy-MM-dd') FROM test_from_unix_time |
There was a problem hiding this comment.
error / fallback reason is more actionable
coderfender
left a comment
There was a problem hiding this comment.
added some comments to help with review
| object CometStringRepeat extends CometExpressionSerde[StringRepeat] { | ||
|
|
||
| override def getCompatibleNotes(): Seq[String] = Seq( | ||
| override def getIncompatibleReasons(): Seq[String] = Seq( |
There was a problem hiding this comment.
There is an approved PR to fix the behavior here
| override def getSupportLevel(expr: FromUnixTime): SupportLevel = { | ||
| expr.format match { | ||
| case Literal(fmt, _) => | ||
| val formatStr = fmt.toString |
Which issue does this PR close?
Closes #4074
Rationale for this change
What changes are included in this PR?
How are these changes tested?