Dwrite commented on code in PR #4810:
URL: https://github.com/apache/calcite/pull/4810#discussion_r2872847595
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -604,14 +604,63 @@ private static boolean selectListRequired(Context
context) {
return false;
}
- /** Visits a Project; called by {@link #dispatch} via reflection. */
+ /**
+ * Extracts the table name from a SqlNode if it represents a simple table
reference.
+ * Returns null for complex nodes like subqueries or joins.
+ *
+ * <p>Examples:
+ * <ul>
+ * <li>"product" → "product"</li>
+ * <li>"foodmart.product" → "product"</li>
+ * <li>"SCOTT"."EMP" → "EMP"</li>
+ * <li>Subquery/Join/Other → null</li>
+ * </ul>
+ *
+ * @param node The SQL node to examine
+ * @return The table name if it's a simple identifier, null otherwise
+ */
+ private @Nullable String extractTableNameFromNode(SqlNode node) {
+ if (node instanceof SqlIdentifier) {
+ SqlIdentifier id = (SqlIdentifier) node;
+ // Return the last component (table name)
+ return id.names.get(id.names.size() - 1);
+ }
+
+ // All other cases: return null
+ return null;
+ }
+ /**
+ * Visits a Project; called by {@link #dispatch} via reflection.
Review Comment:
sure.Updated
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]