PDGGK opened a new issue, #1357:
URL: https://github.com/apache/paimon-rust/issues/1357
### Search before asking
- [x] I searched in the issues and found nothing similar.
### Please describe the bug
Tables partitioned by CHAR, DECIMAL or TIMESTAMP can be created, written and
read, but a statement that names one of their partitions fails during planning.
That covers `ALTER TABLE ... DROP PARTITION`, `TRUNCATE TABLE ... PARTITION`
and `INSERT OVERWRITE ... PARTITION`. A DATE key works with a quoted string and
fails with a DATE literal.
```sql
CREATE TABLE paimon.d.t (id INT, k CHAR(3)) PARTITIONED BY (k);
INSERT INTO paimon.d.t VALUES (1, 'ab');
ALTER TABLE paimon.d.t DROP PARTITION (k = 'ab');
-- Error during planning: Cannot convert 'ab' to Char(CharType { nullable:
true, length: 3 })
```
All three statements fail the same way for each of these, on main at
0be46006:
| Key type | Value in the PARTITION clause | Error |
|---|---|---|
| CHAR(3) | `'ab'` | Cannot convert 'ab' to Char(...) |
| DECIMAL(10,2) | `12.50` | Cannot convert 12.50 to Decimal(...) |
| DECIMAL(10,2) | `'12.50'` | Cannot convert '12.50' to Decimal(...) |
| TIMESTAMP(3) | `'2024-03-01 10:11:12.5'` | Cannot convert '2024-03-01
10:11:12.5' to Timestamp(...) |
| TIMESTAMP(3) | `TIMESTAMP '2024-03-01 10:11:12.5'` | Unsupported partition
value expression |
| DATE | `DATE '2024-03-01'` | Unsupported partition value expression |
`docs/src/sql.md` lists `TRUNCATE TABLE` and `ALTER TABLE ... DROP
PARTITION` as supported for partitioned tables and names no key type limit. An
append-only table can still fall back to `DELETE`, but the same page says
`DELETE` is not supported on primary-key tables, so there a single partition
with such a key cannot be removed from SQL.
I ran this through `SQLContext` from a local build of main (`maturin
develop`, Python 3.13, Linux aarch64 in Docker) with a filesystem catalog.
### Solution
`sql_expr_to_datum` in `sql_context.rs` only converts numbers, VARCHAR,
quoted DATE and booleans. The `CALL` procedures already parse every one of
these types with `parse_partition_value` in `procedures.rs`, so the spec
conversion can use that for the missing types.
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
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]