terrymanu commented on issue #28669:
URL: 
https://github.com/apache/shardingsphere/issues/28669#issuecomment-3621745403

   Problem Understanding
   
     - Running SELECT [Limit1].[AccountID] AS [AccountID] FROM ( SELECT TOP (1) 
[AccountID] AS [AccountID] FROM [Account] ) AS [Limit1], null on 
ShardingSphere-JDBC (SQLServer) throws SQLParsingException; user expected it to 
succeed.
   
     Root Cause
   
     - FROM ... , null is not valid SQL Server syntax; null cannot be a table 
source. ShardingSphere’s SQLServer parser enforces SQL Server rules and rightly 
errors on an invalid table source—this is expected behavior, not a defect.
   
     Issue Analysis
   
     - Native SQL Server also rejects bare null in the FROM clause (e.g., 
“Incorrect syntax near ','/NULL”).
     - ShardingSphere’s SQLParserExecutor.twoPhaseParse validates the SQLServer 
dialect and fails during parsing.
     - To include a constant row, rewrite the SQL:
         - Drop the meaningless , null, keeping only the subquery; or
         - Use CROSS JOIN (SELECT NULL AS dummy) AS t to inject a constant row.
         - If the SQL is generated by an ORM (EF/LINQ, etc.), adjust the ORM 
query/config so it doesn’t emit the invalid , null fragment.
   
     Conclusion
   
     - The observed error comes from invalid SQL input, not a ShardingSphere 
bug.
     - If you believe this SQL should pass on native SQL Server, please share: 
the exact result/error from running it directly on SQL Server (with version), 
and the SQL generation path (ORM and configuration) so we can verify any 
compatibility gap.


-- 
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]

Reply via email to