Gabor Kaszab has posted comments on this change. ( http://gerrit.cloudera.org:8080/13722 )
Change subject: IMPALA-8703: ISO:SQL:2016 datetime patterns - Milestone 1 ...................................................................... Patch Set 22: (9 comments) http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/exprs/timestamp-functions-ir.cc File be/src/exprs/timestamp-functions-ir.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/exprs/timestamp-functions-ir.cc@73 PS20, Line 73: for > Maybe this should be called 'buff' to match the formal parameter name in th Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-parse-util.cc File be/src/runtime/date-parse-util.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-parse-util.cc@135 PS20, Line 135: HECK(dt_ctx. > 'buff' should either be a string* param or the return value of Format() to Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-parse-util.cc@138 PS20, Line 138: int year, month, day; > This probably not necessary. Format should work even if string is not empty Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-parse-util.cc@180 PS20, Line 180: result.append(str_val, str_val_len); > I'm not sure what happens if str_val == nullptr and str_val_len == 0. it can't be nullptr, but I added a dcheck just in case. http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-parse-util.cc@180 PS20, Line 180: result.append(str_val, str_val_len); > No need to create a temp string, you can append char* directly: Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-value.cc File be/src/runtime/date-value.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/date-value.cc@86 PS20, Line 86: ) const { > Again, 'buff' should be a string* param or the return value of Format(). Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/datetime-iso-sql-format-tokenizer.cc File be/src/runtime/datetime-iso-sql-format-tokenizer.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/datetime-iso-sql-format-tokenizer.cc@113 PS20, Line 113: string token_to_probe(*curre > nit: Probably not necessary, L110 and L111 implies that his is true. Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/timestamp-parse-util.cc File be/src/runtime/timestamp-parse-util.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/timestamp-parse-util.cc@218 PS20, Line 218: string TimestampParser::Format(const DateTimeFormatContext& dt_ctx, : const date& d, const time_duration& t) { : DCHECK(dt_ctx.toks.size() > 0); : if (dt_ctx.has_date_toks && d.is_special()) return ""; : if (dt_ctx.has_time_toks && t.is_special()) return ""; : string result; : for (const DateTimeFormatToken& tok: dt_ctx.toks) { : int32_t num_val = -1; : const char* str_val = NULL; : int str_val_len = 0; : switch (tok.type) { : case YEAR: : case ROUND_YEAR: { : num_val = d.year(); : if (tok.len < 4) { : int adjust_factor = std::pow(10, tok.len); : num_val %= adjust_factor; : } : break; : } : case MONTH_IN_YEAR: num_val = d.month().as_number(); break; : case MONTH_IN_YEAR_SLT: { : str_val = d.month().as_short_string(); : str_val_len = 3; : break; : } : case DAY_IN_MONTH: num_val = d.day(); break; : case DAY_IN_YEAR: { : num_val = GetDayInYear(d.year(), d.month(), d.day()); : break; : } : case HOUR_IN_DAY: num_val = t.hours(); break; : case HOUR_IN_HALF_DAY: { : num_val = t.hours(); : if (num_val == 0) num_val = 12; : if (num_val > 12) num_val -= 12; : break; : } : case MERIDIEM_INDICATOR: { : const MERIDIEM_INDICATOR_TEXT* indicator_txt = (tok.len == 2) ? &AM : &AM_LONG; : if (t.hours() >= 12) { : indicator_txt = (tok.len == 2) ? &PM : &PM_LONG; : } : str_val_len = tok.len; : str_val = (isupper(*tok.val)) ? indicator_txt->first : indicator_txt->second; : break; : } : case MINUTE_IN_HOUR: num_val = t.minutes(); break; : case SECOND_IN_MINUTE: num_val = t.seconds(); break; : case SECOND_IN_DAY: { : num_val = t.hours() * 3600 + t.minutes() * 60 + t.seconds(); : break; : } : case FRACTION: { : num_val = t.fractional_seconds(); : if (num_val > 0) for (int j = tok.len; j < 9; ++j) num_val /= 10; : break; : } : case SEPARATOR: : case ISO8601_TIME_INDICATOR: : case ISO8601_ZULU_INDICATOR: { : str_val = tok.val; : str_val_len = tok.len; : break; : } : case TZ_OFFSET: { : break; : } : default: DCHECK(false) << "Unknown date/time format token"; : } : if (num_val > -1) { : string tmp_str = std::to_string(num_val); : if (tmp_str.length() < tok.len) tmp_str.insert(0, tok.len - tmp_str.length(), '0'); : result.append(tmp_str); : } else { : DCHECK(str_val != nullptr && str_val_len > 0); : result.append(str_val, str_val_len); : > Same as comments on DateParser::Format(). Done http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/timestamp-value.cc File be/src/runtime/timestamp-value.cc: http://gerrit.cloudera.org:8080/#/c/13722/20/be/src/runtime/timestamp-value.cc@82 PS20, Line 82: const { > Again, buff should be a string* param or the return value of Format() to em Done -- To view, visit http://gerrit.cloudera.org:8080/13722 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I19d8d097a45ae6f103b6cd1b2d81aad38dfd9e23 Gerrit-Change-Number: 13722 Gerrit-PatchSet: 22 Gerrit-Owner: Gabor Kaszab <gaborkas...@cloudera.com> Gerrit-Reviewer: Attila Jeges <atti...@cloudera.com> Gerrit-Reviewer: Gabor Kaszab <gaborkas...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Comment-Date: Wed, 18 Sep 2019 08:47:14 +0000 Gerrit-HasComments: Yes