Alex Behm has posted comments on this change. Change subject: IMPALA-3163: Fix Decimal to Timestamp casting ......................................................................
Patch Set 5: (14 comments) http://gerrit.cloudera.org:8080/#/c/2791/5/be/src/exprs/decimal-operators-ir.cc File be/src/exprs/decimal-operators-ir.cc: Line 561: // What is the right way to store multiple variables? Store a struct with whatever fields you need. The comment should describe what we are precomputing here and why Line 566: for (int i = 0; i < 9 - scale; i++) { we prefer pre-increments, i.e. ++i here and elsewhere Line 572: *coeffs = (uint64_t)mult << 32 | div; Why not make mult a uint64_t to begin with? Also, we generally avoid C-style casts in favor of c++ style casts (static_cast<>() in this case) Line 580: uint64_t* coeffs = reinterpret_cast<uint64_t*>( const uint64_t* Line 581: context->GetFunctionState(FunctionContext::THREAD_LOCAL)); indent 4 Line 583: int div = ((uint64_t)*coeffs << 32) >> 32; why not precompute these directly? Line 591: // According to my benchmark, this implementation is about 1% faster than the mention more details about this benchmark as well as your findings in the commit msg and not here Line 628: // What is that it has to be uint8_t here (instead of uint64_t)? arbitrary choice of implementing ctx->Free() void* might have been cleaner, but let's not change it now http://gerrit.cloudera.org:8080/#/c/2791/5/be/src/exprs/decimal-operators.h File be/src/exprs/decimal-operators.h: Line 55: static void CastToTimestampValPrepare( please wrap consistently by moving ctx one line up http://gerrit.cloudera.org:8080/#/c/2791/5/fe/src/main/java/com/cloudera/impala/analysis/CastExpr.java File fe/src/main/java/com/cloudera/impala/analysis/CastExpr.java: Line 157: if(toType.isTimestamp() && fromType.isDecimal()) { formatting: space after if Line 158: String beClass = toType.isDecimal() || fromType.isDecimal() ? unused? Line 160: String beSymbol = "impala::" + beClass + "::CastTo" + Function.getUdfType(toType); unused? Line 163: "_ZN6impala16DecimalOperators18CastToTimestampValEPN10impala_udf15FunctionContextERKNS1_10DecimalValE", can you factor out some common parts (e.g. prefix) to make it fix into single line? http://gerrit.cloudera.org:8080/#/c/2791/5/testdata/workloads/functional-query/queries/QueryTest/exprs.test File testdata/workloads/functional-query/queries/QueryTest/exprs.test: Line 2459: select cast(cast(1457473016.1230 as decimal(17,4)) as timestamp) Move this into expr-test.cc When mentioning the JIRA, also add a brief description of what behavior the test is asserting. -- To view, visit http://gerrit.cloudera.org:8080/2791 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iabeea9f4ab4880b2f814408add63c77916e2dba9 Gerrit-PatchSet: 5 Gerrit-Project: Impala Gerrit-Branch: cdh5-trunk Gerrit-Owner: Taras Bobrovytsky <[email protected]> Gerrit-Reviewer: Alex Behm <[email protected]> Gerrit-HasComments: Yes
