Jan Soubusta
03/13/2024, 8:19 AMdate_col + interval '1 month'.
I searched the DOC really thoroughly but cannot find anything relevant...Jan Soubusta
03/13/2024, 1:28 PMselect cast('2024-01-01' as timestamp) + INTERVAL '1' YEAR;Jan Soubusta
03/13/2024, 1:29 PMJan Soubusta
03/13/2024, 1:44 PMrobert zych
03/13/2024, 5:05 PMMayank
timestamp_add function. Perhaps you can file a GH enhancement request for date_add?
@ScalarFunction(names = {"timestampAdd", "timestamp_add", "dateAdd", "date_add"})
public static long timestampAdd(String unit, long interval, long timestamp) {
ISOChronology chronology = ISOChronology.getInstanceUTC();
long millis = DateTimeUtils.getTimestampField(chronology, unit).add(timestamp, interval);
return millis;
}Jan Soubusta
03/13/2024, 5:51 PMselect id,
created_at_timestamp
, cast(created_at_timestamp AS double) AS timeInMs
, timestampAdd('WEEK', 1, created_at_timestamp) as shiftedDate
from githubEvents
WHERE id = 7044874134
Fails with:
SQLParsingError:
org.apache.pinot.sql.parsers.SqlCompilationException: Caught exception while parsing query: select id,
created_at_timestamp
, cast(created_at_timestamp AS double) AS timeInMs
, timestampAdd('WEEK', 1, created_at_timestamp) as shiftedDate
from githubEvents
...
Caused by: org.apache.pinot.sql.parsers.parser.ParseException: Encountered "" at line 4, column 20.
at org.apache.pinot.sql.parsers.parser.SqlParserImpl.generateParseException(SqlParserImpl.java:38633)
at org.apache.pinot.sql.parsers.parser.SqlParserImpl.jj_consume_token(SqlParserImpl.java:38430)
at org.apache.pinot.sql.parsers.parser.SqlParserImpl.TimestampInterval(SqlParserImpl.java:5196)
at org.apache.pinot.sql.parsers.parser.SqlParserImpl.TimestampAddFunctionCall(SqlParserImpl.java:7001)Jan Soubusta
03/13/2024, 5:53 PMselect id,
created_at_timestamp
, cast(created_at_timestamp AS double) AS timeInMs
, timestampAdd(WEEK, 1, created_at_timestamp) as shiftedDate
from githubEvents
WHERE id = 7044874134
Definitely it is not the first time I face to this issue.
Why DB developers have to require sometimes 'WEEK' and sometimes WEEK ? πJan Soubusta
03/13/2024, 5:54 PMrobert zych
03/13/2024, 6:08 PMcreated_at_timestamp using the timestamp data type?Jan Soubusta
03/13/2024, 6:39 PMJan Soubusta
03/13/2024, 6:39 PMselect FROMDATETIME('2024', 'yyyy') as datetime;
This fails:
select TIMESTAMPADD(YEAR, 1, FROMDATETIME('2024', 'yyyy'));
FROMDATETIME produces TIMESTAMP data type.
What am I doing wrong?Jan Soubusta
03/13/2024, 6:52 PMCaused by: org.apache.pinot.sql.parsers.SqlCompilationException: Caught exception while invoking method: public static long org.apache.pinot.common.function.scalar.DateTimeFunctions.timestampAdd(java.lang.String,long,long) with arguments: [YEAR, 1, 1704067200000]
at org.apache.calcite.rel.rules.PinotEvaluateLiteralRule.evaluateLiteralOnlyFunction(PinotEvaluateLiteralRule.java:164)
at org.apache.calcite.rel.rules.PinotEvaluateLiteralRule$EvaluateLiteralShuttle.visitCall(PinotEvaluateLiteralRule.java:131)
at org.apache.calcite.rel.rules.PinotEvaluateLiteralRule$EvaluateLiteralShuttle.visitCall(PinotEvaluateLiteralRule.java:119)
Caused by: java.lang.IllegalArgumentException: Cannot convert value from class: class org.apache.calcite.avatica.util.TimeUnit to class: class java.lang.String
at org.apache.pinot.shaded.com.google.common.base.Preconditions.checkArgument(Preconditions.java:445)
at org.apache.pinot.common.function.FunctionInvoker.convertTypes(FunctionInvoker.java:113)
at org.apache.calcite.rel.rules.PinotEvaluateLiteralRule.evaluateLiteralOnlyFunction(PinotEvaluateLiteralRule.java:160)Jan Soubusta
03/13/2024, 8:05 PMJan Soubusta
03/14/2024, 12:26 PMrobert zych
03/14/2024, 1:50 PMselect TIMESTAMPADD(YEAR, 1, FROMDATETIME('2024', 'yyyy'));?Jan Soubusta
03/14/2024, 4:55 PMSELECT TODATETIME("a_label_ts_day_26d123c51b6740e1bacfd7c7e21d3928_28c4668072285e",
'yyyy-MM-dd') AS "a_label_ts_day_26d123c51b6740e1bacfd7c7e21d3928_08783fee3a5f3d",
"m_f17916e2335060e6b888d17749084758" AS "m_1"
FROM (SELECT DATETRUNC('DAY', "ts") AS "a_label_ts_day_26d123c51b6740e1bacfd7c7e21d3928_28c4668072285e",
SUM(CAST("ActualElapsedTime" AS DOUBLE)) AS "m_f17916e2335060e6b888d17749084758",
TRUE AS "def_m_f17916e2335060e6b888d17749084758"
FROM "airlineStats"
WHERE "ts" >= FROMDATETIME('2024', 'yyyy')
AND "ts" < TIMESTAMPADD(YEAR, 1, FROMDATETIME('2024', 'yyyy'))
GROUP BY DATETRUNC('DAY', "ts")) AS "t2"
WHERE "def_m_f17916e2335060e6b888d17749084758"Jan Soubusta
03/15/2024, 5:02 PMrobert zych
03/15/2024, 8:33 PMJan Soubusta
03/15/2024, 8:40 PMJan Soubusta
03/15/2024, 8:40 PMJan Soubusta
03/15/2024, 8:44 PMrobert zych
03/15/2024, 9:35 PM