morningman opened a new issue, #67364:
URL: https://github.com/apache/doris/issues/67364

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Version
   
   Apache Doris 4.1.3-rc02, commit `31263df4dc1d4d3a27517d264802cd4d6b92c874`
   
   Client: Python + ADBC Flight SQL driver (`adbc_driver_flightsql`), FE 
`arrow_flight_sql_port` = 41070.
   The MySQL/JDBC protocol is used as the control path for comparison.
   
   ### What's Wrong?
   
   Reading a raw `HLL` or `QUANTILE_STATE` aggregate-state column over Arrow 
Flight SQL (Python ADBC) makes the server return `INTERNAL` with an 
`IllegalStateException`. The FE stack goes through `StmtExecutor.sendFields()` 
and fails a `Preconditions.checkState`.
   
   The same query succeeds over MySQL/JDBC (the raw state is shown as `NULL`), 
and it also succeeds over ADBC once the state is converted server-side with 
`HLL_CARDINALITY` / `QUANTILE_PERCENT`.
   
   ### What You Expected?
   
   Flight SQL should return a representable Arrow result. If a raw 
aggregate-state type cannot be represented in Arrow, the server should return a 
clear and stable "unsupported type" error instead of raising an internal 
`IllegalStateException`.
   
   ### How to Reproduce?
   
   1. Start Doris and run the DDL/DML below over MySQL/JDBC.
   2. Connect to the same FE with the Python ADBC Flight SQL driver.
   3. Select the raw state columns; the query fails with `INTERNAL` / 
`IllegalStateException`.
   4. Select the derived scalar values; ADBC returns the result normally.
   
   ```sql
   DROP TABLE IF EXISTS adbc_opaque_state;
   CREATE TABLE adbc_opaque_state (
     k INT,
     h HLL HLL_UNION,
     q QUANTILE_STATE QUANTILE_UNION
   ) AGGREGATE KEY(k)
   DISTRIBUTED BY HASH(k) BUCKETS 1
   PROPERTIES("replication_num"="1");
   
   INSERT INTO adbc_opaque_state
   SELECT 1, HLL_HASH('x'), TO_QUANTILE_STATE(1, 1.0);
   
   -- Fails through Arrow Flight SQL.
   SELECT h, q FROM adbc_opaque_state;
   
   -- Succeeds through Arrow Flight SQL.
   SELECT HLL_CARDINALITY(h), QUANTILE_PERCENT(q, 0.5) FROM adbc_opaque_state;
   ```
   
   Client side:
   
   ```python
   import adbc_driver_flightsql.dbapi as flight_sql
   
   conn = flight_sql.connect(uri="grpc://127.0.0.1:41070",
                             db_kwargs={"username": "root", "password": ""})
   cur = conn.cursor()
   cur.execute("SELECT h, q FROM adbc_opaque_state")
   cur.fetch_arrow_table()
   ```
   
   ### Anything Else?
   
   **Workaround:** convert the internal state to an Arrow-representable scalar 
on the server side first, e.g. `HLL_CARDINALITY()` or `QUANTILE_PERCENT()`.
   
   This is the same family of protocol gap as the raw `BITMAP` case already 
noted in #65182. A decision is needed on whether these types get an engine-side 
Arrow representation or a documented protocol limitation with a clean error.
   
   Tracking issue: #65615
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]

Reply via email to