Hi all can someone tell me why i am getting the f...
# troubleshooting
s
Hi all can someone tell me why i am getting the following error for this query
SELECT
"channel" AS "Group_0",
COUNT(CASE WHEN "eventnumber" = 1 THEN 1 END) AS "Col_0_d1",
ROUND(
(COUNT(CASE WHEN visits = 1 AND eventnumber = 1 AND (first_tab IS NULL OR first_tab = true) THEN 1 END) * 100.0)
/ CAST(COUNT(CASE WHEN eventnumber = 1 THEN 1 END) AS DOUBLE), 2
) AS "Col_1_d1"
FROM
testsignupinfo3
WHERE
"eventtime" BETWEEN CAST('2024-07-01 00:00' AS TIMESTAMP) AND CAST('2024-07-31 23:59' AS TIMESTAMP)
GROUP BY
"channel"
HAVING
COUNT(CASE WHEN eventnumber = 1 THEN 1 END) > 0;
SET enableNullHandling = true;
ProcessingException(errorCode:150, messageSQLParsingError java.lang.Exception: It seems that the query is only supported by the multi-stage engine, please try it by checking the "Use Multi-Stage Engine" box above at org.apache.pinot.controller.api.resources.PinotQueryResource.getQueryResponse(PinotQueryResource.java:250) at org.apache.pinot.controller.api.resources.PinotQueryResource.executeSqlQuery(PinotQueryResource.java:181) at org.apache.pinot.controller.api.resources.PinotQueryResource.handlePostSql(PinotQueryResource.java:120) at jdk.internal.reflect.GeneratedMethodAccessor304.invoke(Unknown Source)) I have not used joins or window functions in the query .So in that case why is throwing an error and insisting that i use the multi stage engine?
x
you need to add the option
useMultistageEngine = true
can you try to remove the where clause and see if it works
basically try to remove some expression see if the query works in v1 format
s
yes i understand that the above option will allow me to run the query on the multistage engine..... but what i am trying to ask is why the above query is not able to run on a single stage engine. Multi stage engines are used only in cases of joins, window functions .Am i right?
x
yes
s
so can i know why i am not able to run in v1. CASE should also be supported in v1 right?
x
can you try to explain the query?
CASE is supported
you might need to follow this syntax
s
i am getting the following error if i remove the WHERE clause
ProcessingException(errorCode:450, message:InternalError: java.io.IOException: Failed : HTTP error code : 500. Root Cause: Cannot convert ColumnDataType:
OBJECT to PinotDataType at org.apache.pinot.controller.api.resources.PinotQueryResource.sendPostRaw(PinotQueryResource.java:418) at org.apache.pinot.controller.api.resources.PinotQueryResource.sendRequestRaw(PinotQueryResource.java:456) at org.apache.pinot.controller.api.resources.PinotQueryResource.sendRequestToBroker(PinotQueryResource.java:350) at org.apache.pinot.controller.api.resources.PinotQueryResource.getQueryResponse(PinotQueryResource.java:270))
even though all the columns defined in my table are of simple data types.
On explaining the query in am getting the following
BROKER_REDUCE(havingFilter:count(case(equals(eventnumber,'1'),'1','null')) > '0',limit:10,postAggregations:round(divide(times(count(case(and(equals(visits,'1'),equals(eventnumber,'1'),or(is_null(first_tab),equals(first_tab,'true'))),'1','null')),'100.0'),cast(count(case(equals(eventnumber,'1'),'1','null')),'DOUBLE')),'2'))	1	0
COMBINE_GROUP_BY	2	1
PLAN_START(numSegmentsForThisPlan:1)	-1	-1
GROUP_BY(groupKeys:channel, aggregations:count(case(equals(eventnumber,'1'),'1','null')), count(case(and(equals(visits,'1'),equals(eventnumber,'1'),or(is_null(first_tab),equals(first_tab,'true'))),'1','null')), count(case(equals(eventnumber,'1'),'1','null')))	3	2
TRANSFORM(case(and(equals(visits,'1'),equals(eventnumber,'1'),or(is_null(first_tab),equals(first_tab,'true'))),'1','null'), case(equals(eventnumber,'1'),'1','null'), channel)	4	3
PROJECT(channel, visits, eventnumber, first_tab)	5	4
DOC_ID_SET	6	5
FILTER_MATCH_ENTIRE_SEGMENT(docs:35462711)	7	6
PLAN_START(numSegmentsForThisPlan:1)	-1	-1
GROUP_BY(groupKeys:channel, aggregations:count(case(equals(eventnumber,'1'),'1','null')), count(case(and(equals(visits,'1'),equals(eventnumber,'1'),or(is_null(first_tab),equals(first_tab,'true'))),'1','null')), count(case(equals(eventnumber,'1'),'1','null')))	3	2
TRANSFORM(case(and(equals(visits,'1'),equals(eventnumber,'1'),or(is_null(first_tab),equals(first_tab,'true'))),'1','null'), case(equals(eventnumber,'1'),'1','null'), channel)	4	3
PROJECT(channel, visits, eventnumber, first_tab)	5	4
DOC_ID_SET	6	5
FILTER_MATCH_ENTIRE_SEGMENT(docs:36325396)
Isn’t this case when used to transform during ingestion?
x
this is runtime
does this query work:
Copy code
SELECT 
  "channel" AS "Group_0",
  COUNT(CASE WHEN "eventnumber" = 1 THEN 1 END) AS "Col_0_d1"
FROM 
  testsignupinfo3
WHERE 
  "eventtime" BETWEEN CAST('2024-07-01 00:00' AS TIMESTAMP) AND CAST('2024-07-31 23:59' AS TIMESTAMP)
GROUP BY 
  "channel"
HAVING 
  COUNT(CASE WHEN eventnumber = 1 THEN 1 END) > 0;
SET enableNullHandling = true;
s
no this doesnt work either. it is asking me to use v2.
which are you referring to as runtime?
x
what about
Copy code
SELECT 
  "channel" AS "Group_0",
  COUNT(*) AS "Col_0_d1"
FROM 
  testsignupinfo3
WHERE 
  "eventtime" BETWEEN CAST('2024-07-01 00:00' AS TIMESTAMP) AND CAST('2024-07-31 23:59' AS TIMESTAMP)
GROUP BY 
  "channel"
you are on latest pinot version right ?
s
no i am using pinot 1.0.0
the above query also doesnt work in v1
x
ah
it’s might be due to the version issue
are you able to test on 1.2.0?
or just latest docker image
there has been a lot of changes/fixes after 1.0 release
s
but someone from my team was able to run queries similar to these in this version.He aran it 2 years back
select channel,sum(sessions) as sess , sum(newusers)*100.0/sum(sessions) as pernewsessions,sum(newusers) as newuserss,sum(isbounce)*100.0/sum(sessions) as bouncerate,sum(noofpages)*1.0/sum(sessions) as pagespersessions,sum(visitduration)*100.0/sum(sessions) as avgsesdur from startree where eventnumber=1 and eventtime>= cast('2022-03-01 00:00:00' AS timestamp) and eventtime<= cast('2022-05-31 23:59:59' AS timestamp) group by channel order by 1 desc
is version upgrade the only way?
x
I think case when is the issue
can you try to rewrite case when in the syntax of
Copy code
CASEWHEN(latitude > 0, 'North', 'South')
s
but the following query also doesnt work
SELECT
"channel" AS "Group_0",
COUNT(*) AS "Col_0_d1"
FROM
testsignupinfo3
WHERE
"eventtime" BETWEEN CAST('2024-07-01 00:00' AS TIMESTAMP) AND CAST('2024-07-31 23:59' AS TIMESTAMP)
GROUP BY
"channel"
x
Copy code
SELECT 
  "channel" AS "Group_0",
  COUNT(*) AS "Col_0_d1"
FROM 
  testsignupinfo3 
GROUP BY 
  "channel"
can you try the latest version
s
yes this query works fine
i dont think i can change versions right now.It will take some time as it has already been deployed in production.So I will only be able to do it after some time
x
i see
then use dateTimeConvert function not CAST for the where clause
m
@Yash Mayya could you take a look?
y
This does seem to be a version issue. The query runs fine on 1.2.0, but not on 1.0.0; I guess Xiang's workaround above is the way to go if upgrade is not possible.
Although I'd highly recommend upgrading, there have been a ton of bug fixes and improvements since 1.0.0
x
If all the fixes are already in 1.2.0 then would suggest to upgrade. Or you can check the fixes then cherry pick and build your own distribution.
y
Oops, my bad, it worked on a 1.3.0-SNAPSHOT build, not on 1.2.0 😞
I'll take a look later today at what exactly the issue is and what fixed it
@Sharon the cast should work on 1.0.0 as well if you change the timestamp literal a little -
2024-07-01 00:00
->
2024-07-01 00:00:00
(
yyyy-mm-dd hh:mm:ss
)
Support for
hh:mm
was added recently in https://github.com/apache/pinot/pull/13609.
s
thanks @Yash ...the query worked after making the changes you mentioned