impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Armstrong (Code Review)" <ger...@cloudera.org>
Subject [Impala-ASF-CR] IMPALA-3894: Changed the behavior parsing 2-digit year values
Date Fri, 28 Jul 2017 01:18:59 GMT
Tim Armstrong has posted comments on this change.

Change subject: IMPALA-3894: Changed the behavior parsing 2-digit year values
......................................................................


Patch Set 4:

(8 comments)

Looks pretty good. No major concerns, we just need some tests and a bit of cleanup to make
it easier to follow.

http://gerrit.cloudera.org:8080/#/c/7530/4//COMMIT_MSG
Commit Message:

Line 16: > select from_unixtime(unix_timestamp('31-AUG-94', 'dd-MMM-yy'),'yyyyMMdd');
Can you add some tests in expr-test for some different cases to cover all of the code paths?

I think you can make the value of "now()" deterministic if you set up a RuntimeState(), and
pass in a TQueryCtx with now_string set.


http://gerrit.cloudera.org:8080/#/c/7530/4/be/src/exprs/timestamp-functions-ir.cc
File be/src/exprs/timestamp-functions-ir.cc:

Line 159:   dt_ctx->now = context->impl()->state()->now();
We should be able to do this during the Prepare() phase of this function. It looks like that's
implemented in UnixAndFromUnixPrepare() according to the function registry: https://github.com/apache/incubator-impala/blob/master/common/function-registry/impala_functions.py#L246


http://gerrit.cloudera.org:8080/#/c/7530/4/be/src/runtime/timestamp-parse-util.cc
File be/src/runtime/timestamp-parse-util.cc:

Line 449:         if (tok_len <= 2) {
You can do this on one line (see https://google.github.io/styleguide/cppguide.html#Conditionals)

  if (tok_len <= 2) realign_year = true;


PS4, Line 549: dt_ctx.now->date()
Let's factor this common subexpression out into a separate variable for readability.


Line 551:     dt_result->year += (century_start_year / 100) * 100;
Could you add a comment giving an example of what the value might be at this point. It's subtle..


Line 555:     if (TimestampValue(parsed_date, parsed_time) <
Could you add a comment giving an example of when we need to increment by 100?


http://gerrit.cloudera.org:8080/#/c/7530/4/be/src/runtime/timestamp-parse-util.h
File be/src/runtime/timestamp-parse-util.h:

Line 139:   /// Current time to determine the actual year when parsing 2-digit year token
nit: add a "." for consistency with other comments.


Line 140:   const TimestampValue* now;
Let's just store a copy of the TimestampValue inline instead of the pointer. Makes it easier
to understand who owns the memory.


-- 
To view, visit http://gerrit.cloudera.org:8080/7530
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I5da761255915dc741f1dcc488fd4ef6ecc385896
Gerrit-PatchSet: 4
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Tianyi Wang <twang@cloudera.com>
Gerrit-Reviewer: Greg Rahn <grahn@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <tarmstrong@cloudera.com>
Gerrit-HasComments: Yes

Mime
View raw message