Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6374

LatticeSuggester throw NullPointerException when agg call covered with cast

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      I changed q1 in org.apache.calcite.materialize.LatticeSuggesterTest#testExpressionEvolution

      It was originally like this

      select
        "num_children_at_home" + 10 as "n10",
        "num_children_at_home" + 14 as "n14",
        sum("num_children_at_home" + 12) as "n12",
        sum("num_children_at_home" + 13) as "n13"
      from "customer"
      group by "num_children_at_home" + 10,   "num_children_at_home" + 14 

      i changed it like following

      select
        "num_children_at_home" + 10 as "n10",
        "num_children_at_home" + 14 as "n14",
        cast(sum("num_children_at_home" + 12) as double) as "n12",
        sum("num_children_at_home" + 13) as "n13"
      from "customer"
      group by "num_children_at_home" + 10,   "num_children_at_home" + 14 

      Re-running the test case throws the following exception

      measure.name
      java.lang.NullPointerException: measure.name
          at java.util.Objects.requireNonNull(Objects.java:228)
          at org.apache.calcite.materialize.LatticeSuggester.deriveAlias(LatticeSuggester.java:290)
          at org.apache.calcite.materialize.LatticeSuggester.lambda$addFrame$3(LatticeSuggester.java:250)
          at org.apache.calcite.util.Util$TransformingList.get(Util.java:2810)
          at java.util.AbstractList$Itr.next(AbstractList.java:358)
          at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
          at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:265)
          at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:238)
          at org.apache.calcite.materialize.Lattice$Measure.<init>(Lattice.java:567)
          at org.apache.calcite.materialize.LatticeSuggester.addFrame(LatticeSuggester.java:240) 
          at org.apache.calcite.materialize.LatticeSuggester.lambda$addQuery$1(LatticeSuggester.java:143)
          at java.util.ArrayList.forEach(ArrayList.java:1259)
          at org.apache.calcite.materialize.LatticeSuggester.addQuery(LatticeSuggester.java:143)
          at org.apache.calcite.materialize.LatticeSuggesterTest$Tester.addQuery(LatticeSuggesterTest.java:851)
          at org.apache.calcite.materialize.LatticeSuggesterTest.testExpressionEvolution(LatticeSuggesterTest.java:551)

      Attachments

        Activity

          People

            Unassigned Unassigned
            allendang allendang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: