cetra3 opened a new issue, #22506:
URL: https://github.com/apache/datafusion/issues/22506
### Describe the bug
Discovered this one while playing around with prepared statements. The type
coercion of placeholders is different between a `PREPARE` statement and the
normal query.
I.e,
The standard select query:
```sql
SELECT $1 = 'x', $1 = s FROM t
```
And
The prepared statement:
```sql
PREPARE p AS SELECT $1 = 'x', $1 = s FROM t
```
Both diverge in their placeholder resolution, and can fail in strange ways
### To Reproduce
This only appears when the types are potentially different. I.e, I saw it
when the type on the table was `Utf8View` but literal strings are `Utf8`.
I did manage to replicated it using the datafusion cli.
I.e, first create a table definition
```sql
CREATE TABLE t(s VARCHAR) AS VALUES ('a');
```
Do the raw query (works fine):
```sql
SELECT $1 = 'x', $1 = s FROM t;
```
Prepare this query:
```sql
PREPARE p AS SELECT $1 = 'x', $1 = s FROM t;
```
This will error with:
```
Error during planning: Expected parameter of type Utf8, got Utf8View:
Conflicting types for id $1
```
### Expected behavior
I'd expect this to work fine
### Additional context
_No response_
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]