@@ -29,7 +29,7 @@ use std::fmt::{self, Formatter};
2929use std:: hash:: Hash ;
3030
3131use datafusion_common:: { plan_err, sql_err, DataFusionError , Result , ScalarValue } ;
32- use sqlparser:: ast;
32+ use sqlparser:: ast:: { self , ValueWithSpan } ;
3333use sqlparser:: parser:: ParserError :: ParserError ;
3434
3535/// The frame specification determines which output rows are read by an aggregate
@@ -368,7 +368,7 @@ fn convert_frame_bound_to_scalar_value(
368368 match units {
369369 // For ROWS and GROUPS we are sure that the ScalarValue must be a non-negative integer ...
370370 ast:: WindowFrameUnits :: Rows | ast:: WindowFrameUnits :: Groups => match v {
371- ast:: Expr :: Value ( ast:: Value :: Number ( value, false ) ) => {
371+ ast:: Expr :: Value ( ValueWithSpan { value : ast:: Value :: Number ( value, false ) , span : _ } ) => {
372372 Ok ( ScalarValue :: try_from_string ( value, & DataType :: UInt64 ) ?)
373373 } ,
374374 ast:: Expr :: Interval ( ast:: Interval {
@@ -379,7 +379,7 @@ fn convert_frame_bound_to_scalar_value(
379379 fractional_seconds_precision : None ,
380380 } ) => {
381381 let value = match * value {
382- ast:: Expr :: Value ( ast:: Value :: SingleQuotedString ( item) ) => item,
382+ ast:: Expr :: Value ( ValueWithSpan { value : ast:: Value :: SingleQuotedString ( item) , span : _ } ) => item,
383383 e => {
384384 return sql_err ! ( ParserError ( format!(
385385 "INTERVAL expression cannot be {e:?}"
@@ -395,14 +395,14 @@ fn convert_frame_bound_to_scalar_value(
395395 // ... instead for RANGE it could be anything depending on the type of the ORDER BY clause,
396396 // so we use a ScalarValue::Utf8.
397397 ast:: WindowFrameUnits :: Range => Ok ( ScalarValue :: Utf8 ( Some ( match v {
398- ast:: Expr :: Value ( ast:: Value :: Number ( value, false ) ) => value,
398+ ast:: Expr :: Value ( ValueWithSpan { value : ast:: Value :: Number ( value, false ) , span : _ } ) => value,
399399 ast:: Expr :: Interval ( ast:: Interval {
400400 value,
401401 leading_field,
402402 ..
403403 } ) => {
404404 let result = match * value {
405- ast:: Expr :: Value ( ast:: Value :: SingleQuotedString ( item) ) => item,
405+ ast:: Expr :: Value ( ValueWithSpan { value : ast:: Value :: SingleQuotedString ( item) , span : _ } ) => item,
406406 e => {
407407 return sql_err ! ( ParserError ( format!(
408408 "INTERVAL expression cannot be {e:?}"
@@ -514,10 +514,10 @@ mod tests {
514514 let window_frame = ast:: WindowFrame {
515515 units : ast:: WindowFrameUnits :: Rows ,
516516 start_bound : ast:: WindowFrameBound :: Preceding ( Some ( Box :: new (
517- ast:: Expr :: Value ( ast:: Value :: Number ( "2" . to_string ( ) , false ) ) ,
517+ ast:: Expr :: value ( ast:: Value :: Number ( "2" . to_string ( ) , false ) ) ,
518518 ) ) ) ,
519519 end_bound : Some ( ast:: WindowFrameBound :: Preceding ( Some ( Box :: new (
520- ast:: Expr :: Value ( ast:: Value :: Number ( "1" . to_string ( ) , false ) ) ,
520+ ast:: Expr :: value ( ast:: Value :: Number ( "1" . to_string ( ) , false ) ) ,
521521 ) ) ) ) ,
522522 } ;
523523
@@ -575,10 +575,9 @@ mod tests {
575575 test_bound ! ( Range , None , ScalarValue :: Null ) ;
576576
577577 // Number
578- let number = Some ( Box :: new ( ast:: Expr :: Value ( ast:: Value :: Number (
579- "42" . to_string ( ) ,
580- false ,
581- ) ) ) ) ;
578+ let number = Some ( Box :: new ( ast:: Expr :: Value (
579+ ast:: Value :: Number ( "42" . to_string ( ) , false ) . into ( ) ,
580+ ) ) ) ;
582581 test_bound ! ( Rows , number. clone( ) , ScalarValue :: UInt64 ( Some ( 42 ) ) ) ;
583582 test_bound ! ( Groups , number. clone( ) , ScalarValue :: UInt64 ( Some ( 42 ) ) ) ;
584583 test_bound ! (
@@ -589,9 +588,9 @@ mod tests {
589588
590589 // Interval
591590 let number = Some ( Box :: new ( ast:: Expr :: Interval ( ast:: Interval {
592- value : Box :: new ( ast:: Expr :: Value ( ast :: Value :: SingleQuotedString (
593- "1" . to_string ( ) ,
594- ) ) ) ,
591+ value : Box :: new ( ast:: Expr :: Value (
592+ ast :: Value :: SingleQuotedString ( "1" . to_string ( ) ) . into ( ) ,
593+ ) ) ,
595594 leading_field : Some ( ast:: DateTimeField :: Day ) ,
596595 fractional_seconds_precision : None ,
597596 last_field : None ,
0 commit comments