[BEAM-2018] refine expression of Calcite method/function#2656
[BEAM-2018] refine expression of Calcite method/function#2656mingmxu wants to merge 2 commits intoapache:DSL_SQLfrom
Conversation
|
R: @jbonofre |
|
@davorbonaci can you also take a peek here? |
| boolean result = true; | ||
| for (BeamSqlExpression exp : operands) { | ||
| BeamSqlPrimitive<Boolean> expOut = exp.evaluate(inputRecord); | ||
| result = result && expOut.getValue(); |
There was a problem hiding this comment.
short-circuit strategy can be applied here?
| boolean result = false; | ||
| for (BeamSqlExpression exp : operands) { | ||
| BeamSqlPrimitive<Boolean> expOut = exp.evaluate(inputRecord); | ||
| result = result || expOut.getValue(); |
There was a problem hiding this comment.
short-circuit strategy can be applied here
| } | ||
| case SMALLINT: | ||
| case TINYINT: | ||
| if (!(fieldValue instanceof Integer)) { |
| throw new InvalidFieldException( | ||
| String.format("[%s] doesn't match type [%s]", fieldValue, fieldType)); | ||
| } else { | ||
| return Integer.valueOf(fieldValue.toString()); |
There was a problem hiding this comment.
It seems that XXX.valueOf() calls in getFieldValue is not necessary? Because the return value of getFieldValue is Object, and since the value and type are checked in addField() method, so type cast in methods like getShort, getInteger are safe?
There was a problem hiding this comment.
sounds right, it's already checked in both Constructor and addField
| @@ -108,24 +107,24 @@ public BeamSQLRow decode(InputStream inStream, org.apache.beam.sdk.coders.Coder. | |||
|
|
|||
| switch (type.getFieldsType().get(idx)) { | |||
| case INTEGER: | |||
There was a problem hiding this comment.
we should use the nested context to corresponds with the encode method?
There was a problem hiding this comment.
My preferred way is NESTED...OUTER, any concern?
| case INTEGER: | ||
| return value instanceof Integer; | ||
| case SMALLINT: | ||
| case TINYINT: |
There was a problem hiding this comment.
Maping sql TINYINT to Java Byte maybe more appropriate?(Both of them are 1 byte long).
| case VARCHAR: | ||
| stringCoder.encode(value.getString(idx), outStream, nested); | ||
| break; | ||
| case TIME: |
There was a problem hiding this comment.
Why Time, Timestamp related code are deleted?
There was a problem hiding this comment.
It's moved to a separated task, as a hard dependency of window support in task 2006.
Changes: 1. revert BEAM dependency to 0.6.0 to avoid impact of changes in master branch; 2. updates as discussion during review; refine BeamSqlRowCoder
|
Retest this please |
|
the failure should be safe to ignore. |
davorbonaci
left a comment
There was a problem hiding this comment.
LGTM; ready for merge to a feature branch modulo a few superficial comments.
dsls/pom.xml
Outdated
| <groupId>org.apache.beam</groupId> | ||
| <artifactId>beam-parent</artifactId> | ||
| <version>0.7.0-SNAPSHOT</version> | ||
| <version>0.6.0</version> |
There was a problem hiding this comment.
Use current version for the parent pom.
dsls/sql/pom.xml
Outdated
| <groupId>org.apache.beam</groupId> | ||
| <artifactId>beam-dsls-parent</artifactId> | ||
| <version>0.7.0-SNAPSHOT</version> | ||
| <version>0.6.0</version> |
There was a problem hiding this comment.
Use current version for the parent pom, but instead overwrite dependencyManagement section they way you need it.
| /** | ||
| * | ||
| */ | ||
| private static final long serialVersionUID = 3445015747629217342L; |
|
@davorbonaci |
|
Retest this please |
In this PR,
BeamSQLFnExecutoris introduced to replaceBeamSQLSpELExecutor, as the executor ofSqlOperatorexpressions.Several common operators are added here as reference, more are needed to cover all operators defined in
org.apache.calcite.sql.fun.SqlStdOperatorTable.