This is an automated email from the ASF dual-hosted git repository.

vogievetsky pushed a commit to branch 26.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/26.0.0 by this push:
     new 1b27863880 account for auto allowing for leading and trailing spaces 
(#14224) (#14227)
1b27863880 is described below

commit 1b2786388059f8eead4072ca58bae0a4d05313aa
Author: Vadim Ogievetsky <[email protected]>
AuthorDate: Mon May 8 15:40:36 2023 -0700

    account for auto allowing for leading and trailing spaces (#14224) (#14227)
---
 web-console/src/druid-models/time/time.ts                          | 2 +-
 web-console/src/helpers/__snapshots__/spec-conversion.spec.ts.snap | 6 +++---
 web-console/src/helpers/spec-conversion.ts                         | 2 +-
 web-console/src/utils/sql.ts                                       | 2 ++
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/web-console/src/druid-models/time/time.ts 
b/web-console/src/druid-models/time/time.ts
index bfd9e88ee2..8443f08888 100644
--- a/web-console/src/druid-models/time/time.ts
+++ b/web-console/src/druid-models/time/time.ts
@@ -53,7 +53,7 @@ const MIN_NANO = MIN_MICRO * 1000;
 const MAX_NANO = MIN_NANO * 1000;
 
 export const AUTO_MATCHER =
-  
/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(
 
((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)$/;
+  
/^\s*([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(
 
((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)\s*$/;
 export const ISO_MATCHER =
   
/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)$/;
 
diff --git a/web-console/src/helpers/__snapshots__/spec-conversion.spec.ts.snap 
b/web-console/src/helpers/__snapshots__/spec-conversion.spec.ts.snap
index ac4dd8655e..a70842ee1c 100644
--- a/web-console/src/helpers/__snapshots__/spec-conversion.spec.ts.snap
+++ b/web-console/src/helpers/__snapshots__/spec-conversion.spec.ts.snap
@@ -10,7 +10,7 @@ WITH "source" AS (SELECT * FROM TABLE(
   )
 ) EXTEND ("event_ts" VARCHAR, "col1" VARCHAR, "col2" VARCHAR, "col3" VARCHAR, 
"col4" VARCHAR, "field1" DOUBLE, "field2" DOUBLE, "field3" DOUBLE, "field4" 
VARCHAR, "field5" VARCHAR, "field6" BIGINT, "field7" DOUBLE))
 SELECT
-  TIME_FLOOR(CASE WHEN CAST("event_ts" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("event_ts" AS BIGINT)) ELSE TIME_PARSE("event_ts") 
END, 'PT1H') AS "__time",
+  TIME_FLOOR(CASE WHEN CAST("event_ts" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("event_ts" AS BIGINT)) ELSE 
TIME_PARSE(TRIM("event_ts")) END, 'PT1H') AS "__time",
   "col1",
   "col2",
   "col3",
@@ -77,7 +77,7 @@ WITH "source" AS (SELECT * FROM TABLE(
   )
 ) EXTEND ("timestamp" VARCHAR, "isRobot" VARCHAR, "channel" VARCHAR, "flags" 
VARCHAR, "isUnpatrolled" VARCHAR, "page" VARCHAR, "diffUrl" VARCHAR, "added" 
BIGINT, "comment" VARCHAR, "commentLength" BIGINT, "isNew" VARCHAR, "isMinor" 
VARCHAR, "delta" BIGINT, "isAnonymous" VARCHAR, "user" VARCHAR, "deltaBucket" 
BIGINT, "deleted" BIGINT, "namespace" VARCHAR, "cityName" VARCHAR, 
"countryName" VARCHAR, "regionIsoCode" VARCHAR, "metroCode" VARCHAR, 
"countryIsoCode" VARCHAR, "regionName" VARCHAR [...]
 SELECT
-  CASE WHEN CAST("timestamp" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("timestamp" AS BIGINT)) ELSE TIME_PARSE("timestamp") 
END AS "__time",
+  CASE WHEN CAST("timestamp" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("timestamp" AS BIGINT)) ELSE 
TIME_PARSE(TRIM("timestamp")) END AS "__time",
   "isRobot",
   "channel",
   "flags",
@@ -159,7 +159,7 @@ WITH "source" AS (SELECT * FROM TABLE(
 ) EXTEND ("timestamp" VARCHAR, "isRobot" VARCHAR, "channel" VARCHAR, "flags" 
VARCHAR, "isUnpatrolled" VARCHAR, "page" VARCHAR, "diffUrl" VARCHAR, "added" 
BIGINT, "comment" VARCHAR, "commentLength" BIGINT, "isNew" VARCHAR, "isMinor" 
VARCHAR, "delta" BIGINT, "isAnonymous" VARCHAR, "user" VARCHAR, "deltaBucket" 
BIGINT, "deleted" BIGINT, "namespace" VARCHAR, "cityName" VARCHAR, 
"countryName" VARCHAR, "regionIsoCode" VARCHAR, "metroCode" VARCHAR, 
"countryIsoCode" VARCHAR, "regionName" VARCHAR))
 SELECT
   --:ISSUE: The spec contained transforms that could not be automatically 
converted.
-  CASE WHEN CAST("timestamp" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("timestamp" AS BIGINT)) ELSE TIME_PARSE("timestamp") 
END AS "__time",
+  CASE WHEN CAST("timestamp" AS BIGINT) > 0 THEN 
MILLIS_TO_TIMESTAMP(CAST("timestamp" AS BIGINT)) ELSE 
TIME_PARSE(TRIM("timestamp")) END AS "__time",
   "isRobot",
   "channel",
   "flags",
diff --git a/web-console/src/helpers/spec-conversion.ts 
b/web-console/src/helpers/spec-conversion.ts
index 62412e7eca..72f48c7923 100644
--- a/web-console/src/helpers/spec-conversion.ts
+++ b/web-console/src/helpers/spec-conversion.ts
@@ -140,7 +140,7 @@ export function convertSpecToSql(spec: any): 
QueryWithContext {
     switch (format) {
       case 'auto':
         timestampColumnType = SqlType.VARCHAR;
-        timeExpression = `CASE WHEN CAST(${timestampColumn} AS BIGINT) > 0 
THEN MILLIS_TO_TIMESTAMP(CAST(${timestampColumn} AS BIGINT)) ELSE 
TIME_PARSE(${timestampColumn}) END`;
+        timeExpression = `CASE WHEN CAST(${timestampColumn} AS BIGINT) > 0 
THEN MILLIS_TO_TIMESTAMP(CAST(${timestampColumn} AS BIGINT)) ELSE 
TIME_PARSE(TRIM(${timestampColumn})) END`;
         break;
 
       case 'iso':
diff --git a/web-console/src/utils/sql.ts b/web-console/src/utils/sql.ts
index 4e63f4a23c..235f8987b9 100644
--- a/web-console/src/utils/sql.ts
+++ b/web-console/src/utils/sql.ts
@@ -21,6 +21,8 @@ import { SqlColumn, SqlExpression, SqlFunction, SqlLiteral, 
SqlStar } from 'drui
 export function timeFormatToSql(timeFormat: string): SqlExpression | undefined 
{
   switch (timeFormat) {
     case 'auto':
+      return SqlExpression.parse('TIME_PARSE(TRIM(?))');
+
     case 'iso':
       return SqlExpression.parse('TIME_PARSE(?)');
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to