@@ -2416,8 +2416,9 @@ public RelNode visitChart(Chart node, CalcitePlanContext context) {
24162416
24172417 // If row or column split does not present or limit equals 0, this is the same as `stats agg
24182418 // [group by col]` because all truncating is performed on the column split
2419- Integer limit = (Integer ) argMap .getOrDefault ("limit" , Chart .DEFAULT_LIMIT ).getValue ();
2420- if (node .getRowSplit () == null || node .getColumnSplit () == null || Objects .equals (limit , 0 )) {
2419+ if (node .getRowSplit () == null
2420+ || node .getColumnSplit () == null
2421+ || Objects .equals (config .limit , 0 )) {
24212422 // The output of chart is expected to be ordered by row split names
24222423 relBuilder .sort (relBuilder .field (0 ));
24232424 return relBuilder .peek ();
@@ -2435,13 +2436,13 @@ public RelNode visitChart(Chart node, CalcitePlanContext context) {
24352436 // Convert the column split to string if necessary: column split was supposed to be pivoted to
24362437 // column names. This guarantees that its type compatibility with useother and usenull
24372438 RexNode colSplit = relBuilder .field (1 );
2438- String columSplitName = relBuilder .peek ().getRowType ().getFieldNames ().get (1 );
2439+ String columnSplitName = relBuilder .peek ().getRowType ().getFieldNames ().get (1 );
24392440 if (!SqlTypeUtil .isCharacter (colSplit .getType ())) {
24402441 colSplit =
24412442 relBuilder .alias (
24422443 context .rexBuilder .makeCast (
24432444 UserDefinedFunctionUtils .NULLABLE_STRING , colSplit , true , true ),
2444- columSplitName );
2445+ columnSplitName );
24452446 }
24462447 relBuilder .project (relBuilder .field (0 ), colSplit , relBuilder .field (2 ));
24472448 RelNode aggregated = relBuilder .peek ();
@@ -2460,7 +2461,7 @@ public RelNode visitChart(Chart node, CalcitePlanContext context) {
24602461 if (config .top ) {
24612462 grandTotal = relBuilder .desc (grandTotal );
24622463 }
2463- // Always set it to null last so that it does not interfere with top / bottom calculation
2464+ // Always set it to null last so that nulls don't interfere with top / bottom calculation
24642465 grandTotal = relBuilder .nullsLast (grandTotal );
24652466 RexNode rowNum =
24662467 PlanUtils .makeOver (
@@ -2486,7 +2487,7 @@ public RelNode visitChart(Chart node, CalcitePlanContext context) {
24862487 relBuilder .call (
24872488 SqlStdOperatorTable .LESS_THAN_OR_EQUAL ,
24882489 relBuilder .field (PlanUtils .ROW_NUMBER_COLUMN_FOR_CHART ),
2489- relBuilder .literal (limit ));
2490+ relBuilder .literal (config . limit ));
24902491 if (!config .useOther ) {
24912492 relBuilder .filter (lteCondition );
24922493 }
@@ -2511,7 +2512,6 @@ public RelNode visitChart(Chart node, CalcitePlanContext context) {
25112512 relBuilder .literal (config .otherStr ));
25122513 }
25132514
2514- String columnSplitName = ((Alias ) node .getColumnSplit ()).getName ();
25152515 String aggFieldName = relBuilder .peek ().getRowType ().getFieldNames ().get (2 );
25162516 relBuilder .project (
25172517 relBuilder .field (0 ),
0 commit comments