dylanhz commented on PR #29508:
URL: https://github.com/apache/flink/pull/29508#issuecomment-6282766372

   > > Hi @RocMarshal, just a little question: Why not return `BIGINT`, as many 
other systems do? This would also keep the return type consistent if `BYTES` 
support is added later.
   > 
   > Thanks @dylanhz
   > 
   > That sounds like a good idea. Would you mind sharing similar 
implementations currently available in other systems? Thank you very much.
   
   @RocMarshal  Here is an AI-assisted comparison of return types across 
several systems:
   
   | System | Function and inputs | SQL return type |
   |---|---|---|
   | 
[MaxCompute](https://www.alibabacloud.com/help/en/maxcompute/user-guide/aggregate-func-bit-count)
 | `BIT_COUNT`: four integer types and `BOOLEAN`; same input types as this PR | 
`BIGINT` |
   | [AnalyticDB for 
MySQL](https://www.alibabacloud.com/help/en/analyticdb/analyticdb-for-mysql/developer-reference/bit-functions-and-operators)
 | `BIT_COUNT`: `BIGINT`, or `DOUBLE` and `VARCHAR` converted to integers | 
`BIGINT` |
   | [Trino](https://trino.io/docs/current/functions/bitwise.html#bit_count) | 
`bit_count(x, bits)`: integers, with a specified width of 2–64 bits | `BIGINT` |
   | [MySQL](https://dev.mysql.com/worklog/task/?id=8699) | `BIT_COUNT`: 
numeric values and binary strings | `BIGINT` |
   | 
[BigQuery](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bit_functions#bit_count)
 | `BIT_COUNT`: `INT64` and `BYTES` | `INT64` |
   | [SQL 
Server](https://learn.microsoft.com/en-us/sql/t-sql/functions/bit-count-transact-sql?view=sql-server-ver17)
 | `BIT_COUNT`: integers and non-LOB binary strings | `BIGINT` |
   | PostgreSQL | `bit_count`: [bit 
strings](https://www.postgresql.org/docs/current/functions-bitstring.html) and 
[bytea](https://www.postgresql.org/docs/current/functions-binarystring.html) | 
`BIGINT` |
   | 
[Snowflake](https://docs.snowflake.com/en/release-notes/bcr-bundles/2026_07/bcr-2417)
 | `BITCOUNT`: integers, `BINARY`, and `VARBINARY` | `BIGINT` ([alias for 
`NUMBER(38,0)`](https://docs.snowflake.com/en/sql-reference/data-types-numeric))
 |
   | [Spark / 
Databricks](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_count)
 | `bit_count`: integers and `BOOLEAN` | `INTEGER` |
   | 
[ClickHouse](https://clickhouse.com/docs/reference/functions/regular-functions/bit-functions#bitcount)
 | `bitCount`: integers and floating-point numbers | `UInt8` |
   | 
[Doris](https://github.com/apache/doris/blob/master/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/BitCount.java#L41)
 | `BIT_COUNT`: integers up to 64 bits / 128-bit `LARGEINT` | `TINYINT` / 
`SMALLINT`, respectively |
   | 
[DuckDB](https://github.com/duckdb/duckdb/blob/main/extension/core_functions/scalar/math/numeric.cpp#L335)
 | `bit_count`: integers / `BIT` strings | `TINYINT` / `BIGINT`, respectively |


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

Reply via email to