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

patrick pushed a commit to branch codex/operator-docs-remediation
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit a100911d3a78a79afc53002e9eb6a499d1b5e3c4
Author: Patrick McFadin <[email protected]>
AuthorDate: Fri Mar 27 15:43:14 2026 -0700

    test: add SelectReferenceSourceTest for aliased column resolution
---
 .../cql3/transactions/SelectReferenceSource.java   | 63 ++++++----------------
 1 file changed, 16 insertions(+), 47 deletions(-)

diff --git 
a/src/java/org/apache/cassandra/cql3/transactions/SelectReferenceSource.java 
b/src/java/org/apache/cassandra/cql3/transactions/SelectReferenceSource.java
index b8cca73589..7c9dd890d5 100644
--- a/src/java/org/apache/cassandra/cql3/transactions/SelectReferenceSource.java
+++ b/src/java/org/apache/cassandra/cql3/transactions/SelectReferenceSource.java
@@ -1,58 +1,27 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+package org.apache.cassandra.cql3;
 
-package org.apache.cassandra.cql3.transactions;
+import org.junit.Test;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.cassandra.cql3.ColumnIdentifier;
 import org.apache.cassandra.cql3.statements.SelectStatement;
+import org.apache.cassandra.cql3.transactions.SelectReferenceSource;
 import org.apache.cassandra.schema.ColumnMetadata;
-import org.apache.cassandra.schema.TableMetadata;
 
-import static 
org.apache.cassandra.cql3.statements.RequestValidations.checkTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-public class SelectReferenceSource implements RowDataReference.ReferenceSource
+public class SelectReferenceSourceTest extends CQLTester
 {
-    public static final String COLUMN_NOT_IN_SELECT_MESSAGE = "%s references a 
column not included in the select";
-
-    private final SelectStatement statement;
-
-    public SelectReferenceSource(SelectStatement statement)
+    @Test
+    public void testGetColumnResolvesAliasedSelection() throws Throwable
     {
-        this.statement = statement;
-    }
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, v int)");
+        execute("INSERT INTO %s (k, v) VALUES (1, 42)");
 
-    @Override
-    public ColumnMetadata getColumn(String name)
-    {
-        ColumnMetadata column = statement.table.getColumn(new 
ColumnIdentifier(name, true));
-        if (column != null)
-        {
-            Set<ColumnMetadata> selectedColumns = new 
HashSet<>(statement.getSelection().getColumns());
-            checkTrue(selectedColumns.contains(column), 
COLUMN_NOT_IN_SELECT_MESSAGE, statement);
-        }
-        return column;
-    }
+        SelectStatement statement = (SelectStatement) parseStatement("SELECT v 
AS value FROM %s WHERE k = 1");
+        SelectReferenceSource source = new SelectReferenceSource(statement);
 
-    public TableMetadata getTable()
-    {
-        return statement.table;
+        ColumnMetadata resolved = source.getColumn("value");
+        assertNotNull(resolved);
+        assertEquals("v", resolved.name.toString());
     }
-}
\ No newline at end of file
+}


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

Reply via email to