VARCHAR and INT comparison in query
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
**Describe the bug**
It does not yield an error when comparing VARCHAR and integer.
```rust
// create local execution context
let ctx = SessionContext::new();
let testdata = datafusion::test_util::arrow_test_data();
ctx.sql(&format!(
"CREATE EXTERNAL TABLE aggregate_test_100 (
c1 VARCHAR NOT NULL,
c2 TINYINT NOT NULL,
c3 SMALLINT NOT NULL,
c4 SMALLINT NOT NULL,
c5 INTEGER NOT NULL,
c6 BIGINT NOT NULL,
c7 SMALLINT NOT NULL,
c8 INT NOT NULL,
c9 INT UNSIGNED NOT NULL,
c10 BIGINT UNSIGNED NOT NULL,
c11 FLOAT NOT NULL,
c12 DOUBLE NOT NULL,
c13 VARCHAR NOT NULL
)
STORED AS CSV
WITH HEADER ROW
LOCATION '{testdata}/csv/aggregate_test_100.csv'"
))
.await?;
let df = ctx.sql( "SELECT c1, c2 FROM aggregate_test_100
WHERE c1 < 10").await?;
assert!(df.collect().await.is_err());
```
**To Reproduce**
Use the code above in a test.
**Expected behavior**
Error throw. In PostgreSQL: `Query Error: error: operator does not exist: character varying < integer`
**Additional context**
NA
Contributor guide
Research direction
The entry point mentioned is SessionContext::sql; begin by turning the supplied CREATE EXTERNAL TABLE and WHERE c1 < 10 example into a regression test. Inspect the SQL comparison and type-coercion path, then verify that the query errors for VARCHAR-versus-integer comparison as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100