Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/19881 )
Change subject: IMPALA-10173: Allow implicit casts between numeric and string types when inserting into table ...................................................................... IMPALA-10173: Allow implicit casts between numeric and string types when inserting into table This patch adds an expiremental query option called ALLOW_UNSAFE_CASTS which allows implicit casting between some numeric types and string types. A new type of compatibility is introduced for this purpose, and the compatibility rule handling is refactored also. The new approach uses an enum to differentiate the compatibility levels, and to make it easier to pass them through methods. The unsafe compatibility is used only in two cases: for set operations and for insert statements. The insert statements and set operations accept unsafe implicitly casted expressions only when the source expressions are constant. The following implicit type casts are enabled in unsafe mode: - String -> Float, Double - String -> Tinyint, Smallint, Int, Bigint - Float, Double -> String - Tinyint, Smallint, Int, Bigint -> String The patch also covers IMPALA-3217, and adds two more rules to handle implicit casting in set operations and insert statements between string types: - String -> Char(n) - String -> Varchar(n) The unsafe implicit casting requires that the source expression must be constant in this case as well. Tests: - tests added to AnalyzeExprsTest.java - new test class added to test_insert.py Change-Id: Iee5db2301216c2e088b4b3e4f6cb5a1fd10600f7 Reviewed-on: http://gerrit.cloudera.org:8080/19881 Reviewed-by: Daniel Becker <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- M be/src/service/query-options.cc M be/src/service/query-options.h M common/thrift/ImpalaService.thrift M common/thrift/Query.thrift M fe/src/main/java/org/apache/impala/analysis/AnalyticExpr.java M fe/src/main/java/org/apache/impala/analysis/Analyzer.java M fe/src/main/java/org/apache/impala/analysis/ArithmeticExpr.java M fe/src/main/java/org/apache/impala/analysis/BinaryPredicate.java M fe/src/main/java/org/apache/impala/analysis/CaseExpr.java M fe/src/main/java/org/apache/impala/analysis/ColumnDef.java M fe/src/main/java/org/apache/impala/analysis/CompoundPredicate.java M fe/src/main/java/org/apache/impala/analysis/Expr.java M fe/src/main/java/org/apache/impala/analysis/FunctionCallExpr.java M fe/src/main/java/org/apache/impala/analysis/InPredicate.java M fe/src/main/java/org/apache/impala/analysis/InsertStmt.java M fe/src/main/java/org/apache/impala/analysis/LikePredicate.java M fe/src/main/java/org/apache/impala/analysis/ModifyStmt.java M fe/src/main/java/org/apache/impala/analysis/NumericLiteral.java M fe/src/main/java/org/apache/impala/analysis/PartitionSpec.java M fe/src/main/java/org/apache/impala/analysis/RangePartition.java M fe/src/main/java/org/apache/impala/analysis/StatementBase.java M fe/src/main/java/org/apache/impala/analysis/TimestampArithmeticExpr.java M fe/src/main/java/org/apache/impala/analysis/TypesUtil.java A fe/src/main/java/org/apache/impala/catalog/BinaryCompatibility.java A fe/src/main/java/org/apache/impala/catalog/CheckEmptyCompatibility.java A fe/src/main/java/org/apache/impala/catalog/CompatibilityRule.java A fe/src/main/java/org/apache/impala/catalog/DefaultCompatibility.java A fe/src/main/java/org/apache/impala/catalog/DiagonalCompatibility.java A fe/src/main/java/org/apache/impala/catalog/FixedUdaCompatibility.java M fe/src/main/java/org/apache/impala/catalog/Function.java M fe/src/main/java/org/apache/impala/catalog/ScalarType.java A fe/src/main/java/org/apache/impala/catalog/StrictOverrideCompatibility.java M fe/src/main/java/org/apache/impala/catalog/Type.java A fe/src/main/java/org/apache/impala/catalog/TypeCompatibility.java A fe/src/main/java/org/apache/impala/catalog/UnsafeCompatibility.java M fe/src/main/java/org/apache/impala/planner/HashJoinNode.java M fe/src/test/java/org/apache/impala/analysis/AnalyzeExprsTest.java M fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java M fe/src/test/java/org/apache/impala/analysis/TypesUtilTest.java A testdata/workloads/functional-query/queries/QueryTest/insert-unsafe.test M tests/query_test/test_insert.py 41 files changed, 1,217 insertions(+), 382 deletions(-) Approvals: Daniel Becker: Looks good to me, approved Impala Public Jenkins: Verified -- To view, visit http://gerrit.cloudera.org:8080/19881 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Iee5db2301216c2e088b4b3e4f6cb5a1fd10600f7 Gerrit-Change-Number: 19881 Gerrit-PatchSet: 12 Gerrit-Owner: Peter Rozsa <[email protected]> Gerrit-Reviewer: Csaba Ringhofer <[email protected]> Gerrit-Reviewer: Daniel Becker <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Peter Rozsa <[email protected]> Gerrit-Reviewer: Tamas Mate <[email protected]>
