File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -718,7 +718,7 @@ def _bitshift_sql(
718718 or (isinstance (this , exp .Cast ) and _is_binary (this ))
719719 )
720720
721- # Deal with binary separately, remember the original type, cast back later, etc.
721+ # Deal with binary separately, remember the original type, cast back later
722722 if is_binary_input :
723723 original_type = this .to if isinstance (this , exp .Cast ) else exp .DataType .build ("BLOB" )
724724
@@ -735,6 +735,11 @@ def _bitshift_sql(
735735 elif expression .args .get ("requires_int128" ):
736736 this .replace (exp .cast (this , exp .DataType .Type .INT128 ))
737737
738+ # Cast shift amount to int in case it's something else
739+ shift_amount = expression .expression
740+ if isinstance (shift_amount , exp .Literal ) and not shift_amount .is_int :
741+ expression .set ("expression" , exp .cast (shift_amount , exp .DataType .Type .INT ))
742+
738743 result_sql = self .binary (expression , operator )
739744
740745 # Wrap in parentheses if parent is a bitwise operator to "fix" DuckDB precedence issue
You can’t perform that action at this time.
0 commit comments