This is an automated email from the ASF dual-hosted git repository.

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fa7088e7d1 Read lookup join dimension columns by their table names 
(#20092)
7fa7088e7d1 is described below

commit 7fa7088e7d145d30dc4ece312ad58ab94059d184
Author: Gonzalo Ortiz Jaureguizar <[email protected]>
AuthorDate: Fri Nov 20 09:26:45 2026 +0100

    Read lookup join dimension columns by their table names (#20092)
    
    * Read lookup join dimension columns by their table names
    
    LookupJoinOperator read the dimension table with the column names of the
    right input DataSchema. The right input is [Project ->] TableScan, and the
    Project output names can be aliases. As a result:
    
    - an alias on a primary key column failed with "not a primary key column";
    - an alias on another column returned null in every row;
    - swapped aliases (a AS b, b AS a) returned the values of the other column.
    
    Add LookupJoinOperator.resolveDimensionColumns, which follows each Project
    InputRef to the TableScanNode column. compileKeyPlan and lookupValues use
    these physical names. compileKeyPlan now also checks that the number of
    resolved columns matches the right schema.
    
    Add LookupJoin.json cases for aliased, swapped and repeated dimension
    columns, and for the planner errors on a filter or a computed column in the
    dimension subquery. Add unit tests in LookupJoinOperatorTest.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    
    * Reorder and prune the dimension projection in LookupJoinOperatorTest
    
    testDimensionColumnsFollowProjectInputRefsNotOutputNames now projects the 
scan
    columns as input refs [2, 0, 2]. The projection reorders, prunes and repeats
    columns, so the test checks the mapping from each output position to its 
table
    column directly. The output names stay misleading table column names.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    
    * Test the constant key pass of LookupJoinOperator behind an alias
    
    testConstantBindsTheTableColumnBehindAnAlias binds the aliased primary key
    column currency (output name rate) to a literal and joins rate_start_date 
to the
    fact table. compileKeyPlan must match the literal against the table column, 
so
    the currency key position takes the constant. With the output names, the
    condition leaves currency open and compileKeyPlan rejects the join.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    
    ---------
    
    Co-authored-by: Gonzalo Ortiz <[email protected]>
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../query/runtime/operator/LookupJoinOperator.java | 58 ++++++++++---
 .../runtime/operator/LookupJoinOperatorTest.java   | 99 +++++++++++++++++++++-
 .../src/test/resources/queries/LookupJoin.json     | 84 +++++++++++++++++-
 3 files changed, 228 insertions(+), 13 deletions(-)

diff --git 
a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LookupJoinOperator.java
 
b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LookupJoinOperator.java
index b83a538950d..234da570b76 100644
--- 
a/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LookupJoinOperator.java
+++ 
b/pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LookupJoinOperator.java
@@ -37,6 +37,9 @@ import org.apache.pinot.core.query.request.ServerQueryRequest;
 import org.apache.pinot.core.query.request.context.QueryContext;
 import org.apache.pinot.query.planner.logical.RexExpression;
 import org.apache.pinot.query.planner.plannode.JoinNode;
+import org.apache.pinot.query.planner.plannode.PlanNode;
+import org.apache.pinot.query.planner.plannode.ProjectNode;
+import org.apache.pinot.query.planner.plannode.TableScanNode;
 import org.apache.pinot.query.runtime.blocks.MseBlock;
 import org.apache.pinot.query.runtime.blocks.RowHeapDataBlock;
 import org.apache.pinot.query.runtime.operator.join.JoinedRowView;
@@ -86,7 +89,7 @@ public class LookupJoinOperator extends MultiStageOperator {
   private final LeafOperator _rightInput;
   private final JoinRelType _joinType;
   private final DimensionTableDataManager _rightTable;
-  private final String[] _rightColumns;
+  private final String[] _dimensionColumns;
   private final DataSchema _resultSchema;
   private final int _resultColumnSize;
   private final List<TransformOperand> _nonEquiEvaluators;
@@ -119,7 +122,7 @@ public class LookupJoinOperator extends MultiStageOperator {
     String rightTableName = queryContext.getTableName();
     _rightTable = 
DimensionTableDataManager.getInstanceByTableName(rightTableName);
     Preconditions.checkState(_rightTable != null, "Failed to find dimension 
table for name: %s", rightTableName);
-    _rightColumns = _rightInput.getDataSchema().getColumnNames();
+    _dimensionColumns = resolveDimensionColumns(node.getInputs().get(1), 
rightTableName);
     _resultSchema = node.getDataSchema();
     _resultColumnSize = _resultSchema.size();
     List<RexExpression> nonEquiConditions = node.getNonEquiConditions();
@@ -137,13 +140,43 @@ public class LookupJoinOperator extends 
MultiStageOperator {
 
     KeyPlan keyPlan =
         compileKeyPlan(node, rightTableName, 
_rightTable.getPrimaryKeyColumns(), _rightInput.getDataSchema(),
-            _leftColumnSize);
+            _dimensionColumns, _leftColumnSize);
     _keySize = keyPlan._sources.length;
     _keySources = keyPlan._sources;
     _keyConstants = keyPlan._constants;
     _neverMatches = keyPlan._neverMatches;
   }
 
+  /// Returns the dimension table column that each column of the right input 
reads.
+  ///
+  /// The planner restricts the right input of a lookup join to `[Project ->] 
TableScan`, and the Project holds input
+  /// references only. The output names of that Project are not table columns 
when the query renames a column
+  /// (`SELECT id AS k`) or projects one twice (the planner then makes the 
second name unique). The dimension table is
+  /// read by column name, so this method follows each Project column to the 
TableScan column that it references. Using
+  /// the output names instead fails when a renamed column is a key column, 
and returns nulls or the values of another
+  /// column otherwise.
+  @VisibleForTesting
+  static String[] resolveDimensionColumns(PlanNode rightInput, String 
tableName) {
+    if (rightInput instanceof TableScanNode) {
+      return ((TableScanNode) rightInput).getColumns().toArray(new String[0]);
+    }
+    Preconditions.checkState(rightInput instanceof ProjectNode && 
rightInput.getInputs().size() == 1
+            && rightInput.getInputs().get(0) instanceof TableScanNode,
+        "Right input of lookup join on dimension table: %s must be a Project 
over a TableScan, got: %s", tableName,
+        rightInput.explain());
+    List<String> scanColumns = ((TableScanNode) 
rightInput.getInputs().get(0)).getColumns();
+    List<RexExpression> projects = ((ProjectNode) rightInput).getProjects();
+    String[] columns = new String[projects.size()];
+    for (int i = 0; i < columns.length; i++) {
+      RexExpression project = projects.get(i);
+      Preconditions.checkState(project instanceof RexExpression.InputRef,
+          "Right input of lookup join on dimension table: %s must project 
columns only, got: %s at position: %s",
+          tableName, project.getClass().getSimpleName(), i);
+      columns[i] = scanColumns.get(((RexExpression.InputRef) 
project).getIndex());
+    }
+    return columns;
+  }
+
   /// Works out where each value of the lookup key comes from.
   ///
   /// The key has one position per dimension table primary key column, in the 
order the dimension table schema declares
@@ -159,12 +192,17 @@ public class LookupJoinOperator extends 
MultiStageOperator {
   /// The method rejects a join condition that cannot produce exactly one 
value per primary key column. Every rejected
   /// case returned no rows or wrong rows before this validation existed, so 
an error is the better outcome. This is
   /// also the contract that the single-stage `lookup` transform function 
enforces.
+  ///
+  /// `dimensionColumns` holds the dimension table column behind each column 
of `rightSchema`, as returned by
+  /// [#resolveDimensionColumns]. The names in `rightSchema` itself can be 
aliases.
   @VisibleForTesting
   static KeyPlan compileKeyPlan(JoinNode node, String tableName, @Nullable 
List<String> primaryKeyColumns,
-      DataSchema rightSchema, int leftColumnSize) {
+      DataSchema rightSchema, String[] dimensionColumns, int leftColumnSize) {
     Preconditions.checkState(CollectionUtils.isNotEmpty(primaryKeyColumns),
         "Failed to find primary key columns for dimension table: %s", 
tableName);
-    String[] rightColumns = rightSchema.getColumnNames();
+    Preconditions.checkState(dimensionColumns.length == rightSchema.size(),
+        "Lookup join on dimension table: %s resolved %s dimension columns for 
a right input of %s columns", tableName,
+        dimensionColumns.length, rightSchema.size());
     int keySize = primaryKeyColumns.size();
     int[] sources = new int[keySize];
     Arrays.fill(sources, KEY_SOURCE_UNBOUND);
@@ -175,7 +213,7 @@ public class LookupJoinOperator extends MultiStageOperator {
     List<Integer> rightKeys = node.getRightKeys();
     int numEquiKeys = leftKeys.size();
     for (int i = 0; i < numEquiKeys; i++) {
-      String rightColumn = rightColumns[rightKeys.get(i)];
+      String rightColumn = dimensionColumns[rightKeys.get(i)];
       int keyPosition = primaryKeyColumns.indexOf(rightColumn);
       Preconditions.checkState(keyPosition >= 0,
           "Lookup join on dimension table: %s has a join key on column: %s, 
which is not a primary key column. "
@@ -189,11 +227,11 @@ public class LookupJoinOperator extends 
MultiStageOperator {
     // Pass 2: bind the remaining key positions from constant equality 
conditions.
     boolean neverMatches = false;
     for (RexExpression nonEquiCondition : node.getNonEquiConditions()) {
-      int rightColumnId = getConstantEqualityColumnId(nonEquiCondition, 
leftColumnSize, rightColumns.length);
+      int rightColumnId = getConstantEqualityColumnId(nonEquiCondition, 
leftColumnSize, dimensionColumns.length);
       if (rightColumnId < 0) {
         continue;
       }
-      int keyPosition = primaryKeyColumns.indexOf(rightColumns[rightColumnId]);
+      int keyPosition = 
primaryKeyColumns.indexOf(dimensionColumns[rightColumnId]);
       if (keyPosition < 0 || sources[keyPosition] != KEY_SOURCE_UNBOUND) {
         continue;
       }
@@ -202,7 +240,7 @@ public class LookupJoinOperator extends MultiStageOperator {
       Object value = literal.getValue();
       if (value != null) {
         checkConstantType(literal, 
rightSchema.getColumnDataType(rightColumnId), tableName,
-            rightColumns[rightColumnId]);
+            dimensionColumns[rightColumnId]);
       }
       constants[keyPosition] = value;
       neverMatches |= value == null;
@@ -367,7 +405,7 @@ public class LookupJoinOperator extends MultiStageOperator {
     ArrayList<Object[]> rows = new ArrayList<>(container.size());
 
     for (Object[] leftRow : container) {
-      Object[] rightRow = _neverMatches ? null : 
_rightTable.lookupValues(getKey(leftRow), _rightColumns);
+      Object[] rightRow = _neverMatches ? null : 
_rightTable.lookupValues(getKey(leftRow), _dimensionColumns);
       if (rightRow != null) {
         List<Object> resultRow = JoinedRowView.of(leftRow, rightRow, 
_resultColumnSize, _leftColumnSize);
         if (_nonEquiEvaluators.isEmpty() || _nonEquiEvaluators.stream()
diff --git 
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LookupJoinOperatorTest.java
 
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LookupJoinOperatorTest.java
index bec6a38f1bb..7a074312bca 100644
--- 
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LookupJoinOperatorTest.java
+++ 
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LookupJoinOperatorTest.java
@@ -28,8 +28,11 @@ import org.apache.commons.lang3.tuple.Pair;
 import org.apache.pinot.common.utils.DataSchema;
 import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
 import org.apache.pinot.query.planner.logical.RexExpression;
+import org.apache.pinot.query.planner.plannode.FilterNode;
 import org.apache.pinot.query.planner.plannode.JoinNode;
 import org.apache.pinot.query.planner.plannode.PlanNode;
+import org.apache.pinot.query.planner.plannode.ProjectNode;
+import org.apache.pinot.query.planner.plannode.TableScanNode;
 import org.apache.pinot.spi.utils.ByteArray;
 import org.testng.annotations.Test;
 
@@ -41,7 +44,8 @@ import static org.testng.Assert.expectThrows;
 
 
 /// Tests [LookupJoinOperator#compileKeyPlan], which decides where each value 
of the dimension table lookup key comes
-/// from.
+/// from, and [LookupJoinOperator#resolveDimensionColumns], which names the 
dimension table columns that the lookup
+/// reads.
 ///
 /// The dimension table is a hash map keyed by the primary key values, so a 
key is only usable when it holds one value
 /// per primary key column, in the order the dimension table schema declares 
them, and with the type of each column.
@@ -208,6 +212,96 @@ public class LookupJoinOperatorTest {
     assertTrue(exception.getMessage().contains("Failed to find primary key 
columns"), exception.getMessage());
   }
 
+  @Test
+  public void testDimensionColumnsOfTableScan() {
+    assertEquals(LookupJoinOperator.resolveDimensionColumns(tableScan(), 
TABLE_NAME),
+        new String[]{"currency", "rate", "rate_start_date"});
+  }
+
+  @Test
+  public void testDimensionColumnsFollowProjectInputRefsNotOutputNames() {
+    // SELECT rate_start_date AS currency, currency AS rate, rate_start_date 
AS rate_start_date0. The projection
+    // reorders the scan columns, prunes "rate" and repeats "rate_start_date", 
and every output name except the last
+    // is another table column.
+    DataSchema projectSchema = new DataSchema(new String[]{"currency", "rate", 
"rate_start_date0"},
+        new ColumnDataType[]{ColumnDataType.LONG, ColumnDataType.STRING, 
ColumnDataType.LONG});
+    ProjectNode project = new ProjectNode(0, projectSchema, 
PlanNode.NodeHint.EMPTY, List.of(tableScan()),
+        List.of(new RexExpression.InputRef(DIM_RATE_START_DATE), new 
RexExpression.InputRef(DIM_CURRENCY),
+            new RexExpression.InputRef(DIM_RATE_START_DATE)));
+    assertEquals(LookupJoinOperator.resolveDimensionColumns(project, 
TABLE_NAME),
+        new String[]{"rate_start_date", "currency", "rate_start_date"});
+  }
+
+  @Test
+  public void testDimensionColumnsRejectComputedProject() {
+    DataSchema projectSchema = new DataSchema(new String[]{"literal"}, new 
ColumnDataType[]{ColumnDataType.INT});
+    ProjectNode project = new ProjectNode(0, projectSchema, 
PlanNode.NodeHint.EMPTY, List.of(tableScan()),
+        List.of(new RexExpression.Literal(ColumnDataType.INT, 1)));
+    IllegalStateException exception = expectThrows(IllegalStateException.class,
+        () -> LookupJoinOperator.resolveDimensionColumns(project, TABLE_NAME));
+    assertTrue(exception.getMessage().contains("must project columns only"), 
exception.getMessage());
+  }
+
+  @Test
+  public void testDimensionColumnsRejectProjectOverFilter() {
+    FilterNode filter = new FilterNode(0, DIM_SCHEMA, PlanNode.NodeHint.EMPTY, 
List.of(tableScan()),
+        new RexExpression.Literal(ColumnDataType.BOOLEAN, 1));
+    ProjectNode project = new ProjectNode(0, DIM_SCHEMA, 
PlanNode.NodeHint.EMPTY, List.of(filter),
+        List.of(new RexExpression.InputRef(DIM_CURRENCY), new 
RexExpression.InputRef(DIM_RATE),
+            new RexExpression.InputRef(DIM_RATE_START_DATE)));
+    IllegalStateException exception = expectThrows(IllegalStateException.class,
+        () -> LookupJoinOperator.resolveDimensionColumns(project, TABLE_NAME));
+    assertTrue(exception.getMessage().contains("must be a Project over a 
TableScan"), exception.getMessage());
+  }
+
+  @Test
+  public void testKeyBindsTheTableColumnBehindAnAlias() {
+    // SELECT currency AS rate, rate AS currency, rate_start_date FROM 
dim_tbl, joined
+    // ON dim.rate = fact.currency AND dim.rate_start_date = 
fact.rate_start_date. The output name "rate" is the table
+    // column "currency", so matching output names against the primary key 
would reject the condition.
+    DataSchema aliasedSchema = new DataSchema(new String[]{"rate", "currency", 
"rate_start_date"},
+        new ColumnDataType[]{ColumnDataType.STRING, ColumnDataType.INT, 
ColumnDataType.LONG});
+    JoinNode node = new JoinNode(0, aliasedSchema, PlanNode.NodeHint.EMPTY, 
List.of(), JoinRelType.INNER,
+        List.of(FACT_CURRENCY, FACT_RATE_START_DATE), List.of(0, 2), 
List.of(), JoinNode.JoinStrategy.LOOKUP);
+    LookupJoinOperator.KeyPlan keyPlan = 
LookupJoinOperator.compileKeyPlan(node, TABLE_NAME, PRIMARY_KEY_COLUMNS,
+        aliasedSchema, DIM_SCHEMA.getColumnNames(), LEFT_COLUMN_SIZE);
+    assertEquals(keyPlan._sources[KEY_CURRENCY], FACT_CURRENCY);
+    assertEquals(keyPlan._sources[KEY_RATE_START_DATE], FACT_RATE_START_DATE);
+  }
+
+  @Test
+  public void testConstantBindsTheTableColumnBehindAnAlias() {
+    // SELECT currency AS rate, rate AS currency, rate_start_date FROM 
dim_tbl, joined
+    // ON dim.rate = 'gbp' AND dim.rate_start_date = fact.rate_start_date. The 
constant pass must also match the table
+    // column "currency" behind the output name "rate", or the condition 
leaves the currency key position open.
+    DataSchema aliasedSchema = new DataSchema(new String[]{"rate", "currency", 
"rate_start_date"},
+        new ColumnDataType[]{ColumnDataType.STRING, ColumnDataType.INT, 
ColumnDataType.LONG});
+    JoinNode node = new JoinNode(0, aliasedSchema, PlanNode.NodeHint.EMPTY, 
List.of(), JoinRelType.INNER,
+        List.of(FACT_RATE_START_DATE), List.of(2), 
List.of(dimEqualsConstant(0, ColumnDataType.STRING, "gbp")),
+        JoinNode.JoinStrategy.LOOKUP);
+    LookupJoinOperator.KeyPlan keyPlan = 
LookupJoinOperator.compileKeyPlan(node, TABLE_NAME, PRIMARY_KEY_COLUMNS,
+        aliasedSchema, DIM_SCHEMA.getColumnNames(), LEFT_COLUMN_SIZE);
+    assertEquals(keyPlan._constants[KEY_CURRENCY], "gbp");
+    assertEquals(keyPlan._sources[KEY_RATE_START_DATE], FACT_RATE_START_DATE);
+    assertFalse(keyPlan._neverMatches);
+  }
+
+  @Test
+  public void testDimensionColumnsMustMatchRightSchema() {
+    JoinNode node = new JoinNode(0, DIM_SCHEMA, PlanNode.NodeHint.EMPTY, 
List.of(), JoinRelType.INNER,
+        List.of(FACT_CURRENCY), List.of(DIM_CURRENCY), List.of(), 
JoinNode.JoinStrategy.LOOKUP);
+    IllegalStateException exception = expectThrows(IllegalStateException.class,
+        () -> LookupJoinOperator.compileKeyPlan(node, TABLE_NAME, 
PRIMARY_KEY_COLUMNS, DIM_SCHEMA,
+            new String[]{"currency"}, LEFT_COLUMN_SIZE));
+    assertTrue(exception.getMessage().contains("resolved 1 dimension columns 
for a right input of 3 columns"),
+        exception.getMessage());
+  }
+
+  private static TableScanNode tableScan() {
+    return new TableScanNode(0, DIM_SCHEMA, PlanNode.NodeHint.EMPTY, 
List.of(), "dim_tbl",
+        List.of(DIM_SCHEMA.getColumnNames()));
+  }
+
   private static final DataSchema DECIMAL_DIM_SCHEMA =
       new DataSchema(new String[]{"amount"}, new 
ColumnDataType[]{ColumnDataType.BIG_DECIMAL});
   private static final DataSchema BYTES_DIM_SCHEMA =
@@ -234,7 +328,8 @@ public class LookupJoinOperatorTest {
     JoinNode node =
         new JoinNode(0, dimSchema, PlanNode.NodeHint.EMPTY, List.of(), 
JoinRelType.INNER, leftKeys, rightKeys,
             nonEquiConditions, JoinNode.JoinStrategy.LOOKUP);
-    return LookupJoinOperator.compileKeyPlan(node, TABLE_NAME, 
primaryKeyColumns, dimSchema, LEFT_COLUMN_SIZE);
+    return LookupJoinOperator.compileKeyPlan(node, TABLE_NAME, 
primaryKeyColumns, dimSchema, dimSchema.getColumnNames(),
+        LEFT_COLUMN_SIZE);
   }
 
   /// Builds a `dim_column = constant` condition. Non-equi conditions index 
the joined row, so the dimension table
diff --git a/pinot-query-runtime/src/test/resources/queries/LookupJoin.json 
b/pinot-query-runtime/src/test/resources/queries/LookupJoin.json
index ab9810e917f..eabf6aecfc5 100644
--- a/pinot-query-runtime/src/test/resources/queries/LookupJoin.json
+++ b/pinot-query-runtime/src/test/resources/queries/LookupJoin.json
@@ -414,5 +414,87 @@
         "ignoreLiteMode": true
       }
     ]
+  },
+  "lookup_join_aliased_dimension_columns": {
+    "comment": "The dimension side of a lookup join is a Project over a 
TableScan. The Project output names can be aliases, so the lookup must read the 
dimension table by the physical column names that the Project references.",
+    "tables": {
+      "fact_tbl": {
+        "schema": [
+          {"name": "dim_key", "type": "INT"}
+        ],
+        "inputs": [
+          [1],
+          [2],
+          [3]
+        ]
+      },
+      "dim_tbl": {
+        "schema": [
+          {"name": "id", "type": "INT"},
+          {"name": "a", "type": "STRING"},
+          {"name": "b", "type": "STRING"}
+        ],
+        "inputs": [
+          [1, "a1", "b1"],
+          [2, "a2", "b2"]
+        ],
+        "replicated": true,
+        "isDimTable": true,
+        "primaryKeyColumns": ["id"]
+      }
+    },
+    "queries": [
+      {
+        "description": "Aliases that swap two dimension columns",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.a, d.b FROM {fact_tbl} f JOIN (SELECT id, a AS b, b AS a FROM {dim_tbl}) d ON 
f.dim_key = d.id",
+        "outputs": [
+          [1, "b1", "a1"],
+          [2, "b2", "a2"]
+        ],
+        "ignoreLiteMode": true
+      },
+      {
+        "description": "Alias on the primary key column",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.a FROM {fact_tbl} f JOIN (SELECT id AS k, a FROM {dim_tbl}) d ON f.dim_key = 
d.k",
+        "outputs": [
+          [1, "a1"],
+          [2, "a2"]
+        ],
+        "ignoreLiteMode": true
+      },
+      {
+        "description": "Alias on a non-key column",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.x FROM {fact_tbl} f LEFT JOIN (SELECT id, a AS x FROM {dim_tbl}) d ON 
f.dim_key = d.id",
+        "outputs": [
+          [1, "a1"],
+          [2, "a2"],
+          [3, null]
+        ],
+        "ignoreLiteMode": true
+      },
+      {
+        "description": "A filter inside the dimension subquery is rejected, 
because the lookup cannot apply it",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.a FROM {fact_tbl} f JOIN (SELECT id, a FROM {dim_tbl} WHERE b = 'b1') d ON 
f.dim_key = d.id",
+        "expectedException": ".*(Project over (a )?TableScan|right side deeper 
than 2 levels).*",
+        "outputs": [],
+        "ignoreLiteMode": true
+      },
+      {
+        "description": "A computed column in the dimension subquery is 
rejected, because the lookup reads table columns only",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.u FROM {fact_tbl} f JOIN (SELECT id, UPPER(a) AS u FROM {dim_tbl}) d ON 
f.dim_key = d.id",
+        "expectedException": ".*(identifier \\(RexInputRef\\) only 
Project|must project columns only).*",
+        "outputs": [],
+        "ignoreLiteMode": true
+      },
+      {
+        "description": "A dimension column projected twice",
+        "sql": "SELECT /*+ joinOptions(join_strategy='lookup') */ f.dim_key, 
d.a, d.a2 FROM {fact_tbl} f JOIN (SELECT id, a, a AS a2 FROM {dim_tbl}) d ON 
f.dim_key = d.id",
+        "outputs": [
+          [1, "a1", "a1"],
+          [2, "a2", "a2"]
+        ],
+        "ignoreLiteMode": true
+      }
+    ]
   }
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to