graup commented on issue #1563:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/issues/1563#issuecomment-2582492517

   Hi! Just a small note since I started playing around with this.  I assume 
it's because it's not implemented yet but anyway to keep track: it seems 
currently that Function args don't have a span, and also the Function span only 
covers the function name, not its arguments. So for `CURRENT_DATE('UTC')`, the 
ast node for the Function expr has a span containing only `CURRENT_DATE` (and 
func.args has an empty span). I'd expect the function expr span to cover the 
whole expression including the parentheses.
   
   If I can help in anyway (like writing a test case), I'd be happy to 
contribute.
   
   Very tangential, it would be useful if there was a helper function to 
convert line-column-based locations to byte offsets. (My use case is 
implementing a fixer without rebuilding the SQL from the AST, just applying 
fixed locally to individual nodes.)
   
   Input: `SELECT CURRENT_DATE(),\nCURRENT_DATE('UTC')`
   Output: `
   [Query(Query { with: None, body: Select(Select { select_token: TokenWithSpan 
{ token: Word(Word { value: "SELECT", quote_style: None, keyword: SELECT }), 
span: Span(Location(1,1)..Location(1,7)) }, distinct: None, top: None, 
top_before_distinct: false, projection: [UnnamedExpr(Function(Function { name: 
ObjectName([Ident { value: "CURRENT_DATE", quote_style: None, span: 
Span(Location(1,8)..Location(1,20)) }]), uses_odbc_syntax: false, parameters: 
None, args: List(FunctionArgumentList { duplicate_treatment: None, args: [], 
clauses: [] }), filter: None, null_treatment: None, over: None, within_group: 
[] })), UnnamedExpr(Function(Function { name: ObjectName([Ident { value: 
"CURRENT_DATE", quote_style: None, span: Span(Location(2,1)..Location(2,13)) 
}]), uses_odbc_syntax: false, parameters: None, args: List(FunctionArgumentList 
{ duplicate_treatment: None, args: 
[Unnamed(Expr(Value(SingleQuotedString("UTC"))))], clauses: [] }), filter: 
None, null_treatment: None, over: None, within_gro
 up: [] }))], into: None, from: [], lateral_views: [], prewhere: None, 
selection: None, group_by: Expressions([], []), cluster_by: [], distribute_by: 
[], sort_by: [], having: None, named_window: [], qualify: None, 
window_before_qualify: false, value_table_mode: None, connect_by: None }), 
order_by: None, limit: None, limit_by: [], offset: None, fetch: None, locks: 
[], for_clause: None, settings: None, format_clause: None })]
   `


-- 
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-unsubscr...@datafusion.apache.org

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


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

Reply via email to