yashmayya commented on code in PR #15263: URL: https://github.com/apache/pinot/pull/15263#discussion_r2000856836
########## pinot-query-planner/src/test/resources/queries/JoinPlans.json: ########## @@ -405,10 +405,10 @@ "\nLogicalProject(col1=[$0])", "\n LogicalJoin(condition=[AND(=($0, $3), =($1, $4), >($2, $5))], joinType=[inner])", "\n PinotLogicalExchange(distribution=[hash[0, 1]])", - "\n LogicalProject(col1=[$0], col2=[$1], col4=[$3])", + "\n LogicalProject(col1=[$0], col2=[$1], EXPR$0=[CAST($3):DECIMAL(1000, 982) NOT NULL])", Review Comment: The scale is 982 btw, the precision is 1000 here. I found out that this is actually coming from type coercion during the SQL -> Rel conversion phase, where the casts are being applied because the comparison (`>`) is being made on different types. One is `DECIMAL(1000, 1000)` (the `BigDecimal` column using default scale / precision) and the other is `DECIMAL(19, 1)` (`0.5` is `DECIMAL(2, 1)` and we're multiplying it with a `BIGINT` value). The logic that computes the resultant precision and scale when coercing two decimal types is here - https://github.com/apache/calcite/blob/9b51667eebc825d5d3ece72cfcdb5d2efaa2d56f/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java#L460-L498. It's a little convoluted, but the resultant scale of 982 is arrived at like this: `Math.min(maxScale, Math.min(Math.max(s1, s2), maxPrecision - Math.min(maxPrecision, Math.max(p1 - s1, p2 - s2))))` So this unexpected value does seem to be because we're using the same max and default value for scale and precision, but I'm not convinced that this is an issue given the large values we're using. For reference, Calcite seems to be using 0 as the default scale for `DECIMAL` types and max precision for default precision (which is 19 in Calcite). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org