-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CALCITE-5700] Add ARRAY_SIZE, ARRAY_REPEAT function (enabled in Spar… #3198
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
Conversation
comment:
|
hi @JiajunBernoulli could you also help review? |
CI failed, please fix them. |
@JiajunBernoulli ci passed |
if (count == null) { | ||
return null; | ||
} | ||
return Collections.nCopies((Integer) count, element); |
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.
Can it be Long?
I am worried that the Integer will fail for Long.
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.
@JiajunBernoulli it only can be integer in spark, i comments it before.
override def inputTypes: Seq[AbstractDataType] = Seq(AnyDataType, IntegerType)
"No match found for function signature ARRAY_REPEAT\\(<NUMERIC>, <NUMERIC>\\)", false); | ||
|
||
final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK); | ||
f.checkScalar("array_repeat(1, 2)", "[1, 1]", |
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.
If count <= 0, it is easy to understand for error message?
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 check the spark it will be to zero.
"No match found for function signature ARRAY_SIZE\\(<INTEGER ARRAY>\\)", false); | ||
|
||
final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK); | ||
f.checkScalar("array_size(array[1])", "1", |
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 as above.
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.
array type and element type is different.
array type nullable which indicates wether it is nullable, the value is null
element type nullable which indicates wether the element is nullable, the value is [null, ...] like this
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.
Ok.
@@ -629,6 +629,7 @@ public enum BuiltInMethod { | |||
SUBMULTISET_OF(SqlFunctions.class, "submultisetOf", Collection.class, | |||
Collection.class), | |||
ARRAY_DISTINCT(SqlFunctions.class, "distinct", List.class), | |||
ARRAY_REPEAT(SqlFunctions.class, "repeat", Object.class, Integer.class), |
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.
Would Long.class be better?
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.
why?
fix all your review @JiajunBernoulli thanks |
Can we declare the type of the element? Here is code smells link: https://sonarcloud.io/project/issues?resolved=false&types=CODE_SMELL&pullRequest=3198&id=apache_calcite&open=AYgY9shmOpxb3UapS_aX |
fixed, Thank you for your very detailed code review. @JiajunBernoulli |
Kudos, SonarCloud Quality Gate passed! |
hi @JiajunBernoulli squash the commits and ci passed, will it be merged now, thanks |
If there are no other suggestions, I will merge tomorrow. |
ARRAY_SIZE - Returns the size of an array.
ARRAY_REPEAT - Returns the array containing element count times.
For more details
https://spark.apache.org/docs/latest/api/sql/index.html