You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "bombsimon (via GitHub)" <gi...@apache.org> on 2026/01/08 14:42:56 UTC

[PR] fix: qualified column names with SQL keywords parse as identifiers [datafusion-sqlparser-rs]

bombsimon opened a new pull request, #2157:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2157

   Since v0.55.0, qualified column names using SQL keywords failed to parse. For example, `T.interval` in `PARTITION BY T.key, T.interval ORDER BY ...` was incorrectly interpreted as an INTERVAL expression instead of a column.
   
   In `3e90a18` changed `parse_compound_expr` to use `parse_subexpr()` for tokens after `.`, causing keywords like INTERVAL, CASE, CAST, etc. to be treated as expression starters.
   
   Explicitly handle `Token::Word` in `parse_compound_expr` by treating it as an identifier. If followed by `(` (excluding the `(+)` outer join operator), parse as a method call. This restores the original behavior where words after `.` were always converted to identifiers.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: qualified column names with SQL keywords parse as identifiers [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2157:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2157#discussion_r2716560841


##########
src/parser/mod.rs:
##########
@@ -1856,6 +1856,21 @@ impl<'a> Parser<'a> {
                         chain.push(AccessExpr::Dot(expr));
                         self.advance_token(); // The consumed string
                     }
+                    // Handle words (including keywords like INTERVAL) as identifiers

Review Comment:
   Can we instead of having a new clause (which duplicates some edge cases), we can extend the catch all branch to be more strict around what we're expecting. I think that makes it easier to detect if we were supposed to parse the expression as an identifier. e.g.
   ```rust
   // Fallback ...
   _  => {
   	// Parse any of the suffix expressions we expect to follow the dot operator.
   	let expr = self.maybe_parser(|parser| {
   		let expr = parser.parse_subexpr()?;
   		if matches!(
   			expr,
   			CompoundFieldAccess {...} |
   			CompoundIdentifier(_) |
   			Identifier(_) |
   			Value |
   			Function {..}
   		) {
   			Some(expr)
   		}
   	});
   
   	match expr {
   		// As usual
   		Some(CompoundFieldAccess{..}) => {..}
   		Some(CompoundIdentifier(_)) => {...}
   		Some(expr) => {...}
   		// If its not a suffix we expect, accept only if its an identifier.
   		None => {
   			chain.push(AccessExpr::Dot(Expr::Identifier(self.parse_identifier()?)));
   		}
   	}
   }
   ```



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: qualified column names with SQL keywords parse as identifiers [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #2157:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2157


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org