How should PRQL deal with operands of different data types? #4305
Replies: 2 comments
-
Oh gosh!! Nice example. Yes, I think raising an error where possible makes sense with these. There's an issue of "values in the columns act differently to literal values" — i.e. But I don't think this presents the same problems as #4289, since I don't think there's ever a reason to need |
Beta Was this translation helpful? Give feedback.
-
In the Playground, DuckDB does throw errors for both of these; from [{a=1}]
select {
b = "foo" + 7,
c = "7" + 7,
} However it would be great if PRQL was strongly typed and could point this out to you ahead of time as well as in the LSP. |
Beta Was this translation helpful? Give feedback.
-
In SQL
"foo" + 7
became""
while"7" + 7
became14
.In JavaScript:
"foo" + 7
becomes"foo7"
"7" + 7
becomes77
"foo" - 7
becomesNaN
"7" - 7
becomes0
.In Python you get a
TypeError
.Implicit type conversion can be convenient but it can also be a source of bugs. Explicit type conversions could be an alternative.
Beta Was this translation helpful? Give feedback.
All reactions