-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
DuckDB's ODBC driver incorrectly reports precision and scale information for DECIMAL/NUMERIC columns when using SQLColAttribute and SQLDescribeCol functions.
Current Behavior
SQLColAttribute issues:
SQL_DESC_PRECISION: Always returns 38 (maximum precision) instead of the actual column precisionSQL_DESC_SCALE: Always returns 38 instead of the actual column scale- According to https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlcolattribute-function,
SQL_DESC_PRECISIONshould return "the applicable precision" for numeric data types
SQLDescribeCol issues:
- ColumnSize parameter: Returns precision + scale instead of just the precision
- According to https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/column-size, for
SQL_DECIMALandSQL_NUMERICtypes, ColumnSize should be "the defined number of digits" (i.e., the precision only) - DecimalDigits parameter: Correctly returns the scale ✓
Examples
| Column Declaration | SQLColAttribute Returns(Precision/Scale) | SQLDescribeCol Returns(ColumnSize/DecimalDigits) | Expected Values(Precision/Scale) |
|---|---|---|---|
DECIMAL(5,2) |
38/38 | 7/2 | 5/2 |
DECIMAL(8,4) |
38/38 | 12/4 | 8/4 |
DECIMAL(10,9) |
38/38 | 19/9 | 10/9 |
DECIMAL(30,9) |
38/38 | 39/9 | 30/9 |
DECIMAL(38,0) |
38/38 | 38/0 | 38/0 |
DECIMAL(38,37) |
38/38 | 75/37 | 38/37 |
NUMERIC(5,2) |
38/38 | 7/2 | 5/2 |
NUMERIC(8,4) |
38/38 | 12/4 | 8/4 |
Takeaway
- SQLColAttribute always returns 38 for both precision and scale
- SQLDescribeCol returns precision + scale for ColumnSize (e.g., 5+2=7 for
DECIMAL(5,2))
Expected Behavior
- SQLColAttribute with
SQL_DESC_PRECISION: Should return the actual precision (e.g., 5 forDECIMAL(5,2)) - SQLColAttribute with
SQL_DESC_SCALE: Should return the actual scale (e.g., 2 forDECIMAL(5,2)) - SQLDescribeCol ColumnSize: Should return only the precision (e.g., 5 for
DECIMAL(5,2)) - SQLDescribeCol DecimalDigits: Should return the scale (currently working correctly)
Fork + possible fix n' tests
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels