{"record":{"id":"0a85a5fe9f255df0","repo":"dbt-labs/dbt-core","slug":"detected-columns-with-numeric-type-and-unspecified","errorCode":null,"errorMessage":"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: {col_naked_numeric}`","messagePattern":"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: (.+?)`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/dbt-loader/src/dbt_macro_assets/dbt-adapters/macros/adapters/columns.sql","lineNumber":77,"sourceCode":"    {%- set col_err = [] -%}\n    {%- set col_naked_numeric = [] -%}\n    select\n    {% for i in columns %}\n      {%- set col = columns[i] -%}\n      {%- if col['data_type'] is not defined -%}\n        {%- do col_err.append(col['name']) -%}\n      {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n      {#-- TYPE CHECK: col['data_type'] is optional[string] but user have this constraint --#}\n      {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n        {%- do col_naked_numeric.append(col['name']) -%}\n      {%- endif -%}\n      {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n      {{ cast('null', col['data_type']) }} as {{ col_name }}{{ \", \" if not loop.last }}\n    {%- endfor -%}\n    {%- if (col_err | length) > 0 -%}\n      {{ exceptions.column_type_missing(column_names=col_err) }}\n    {%- elif (col_naked_numeric | length) > 0 -%}\n      {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n    {%- endif -%}\n{% endmacro %}\n\n-- funcsign: (string, optional[string]) -> list[base_column]\n{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n    {% set columns = [] %}\n    {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n    {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n    {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n    {{ return(column_schema) }}\n{% endmacro %}\n\n-- here for back compat\n-- funcsign: (string) -> list[string]\n{% macro get_columns_in_query(select_sql) -%}\n  {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-loader/src/dbt_macro_assets/dbt-adapters/macros/adapters/columns.sql#L59-L95","documentation":"This warning is emitted when a model column resolves to a numeric (NUMERIC/DECIMAL) type without an explicit precision and scale. Without precision/scale, the database applies its default, which can silently round or truncate values. dbt raises it during get-empty-relation / get_column_schema_from_query work when casting columns via cast().","triggerScenarios":"A column's data_type is a bare numeric type (e.g. 'numeric', 'decimal') with no '(p,s)' specifier while dbt builds the empty relation or derives a schema from a query; the column passes the col_err check but lands in col_naked_numeric.","commonSituations":"Inferencing schemas fromCTAS/scratch relations where types come back as unadorned 'numeric'; writing user-defined column types in a model contract without precision; adapters whose default numeric precision differs from what the user expects.","solutions":["Add explicit precision and scale to the column type, e.g. cast the column to numeric(38, 9) instead of numeric.","If using model contracts, set the data_type in the contract's columns block to numeric(p, s).","If the database's default numeric behavior is acceptable, acknowledge the warning and move on — it is non-fatal."],"exampleFix":"// before\n{{ cast('null', 'numeric') }} as my_col\n// after\n{{ cast('null', 'numeric(38, 9)') }} as my_col","handlingStrategy":"validation","validationCode":"# dbt schema.yml / model contract check before running\nmodels:\n  - name: my_model\n    columns:\n      - name: my_col\n        data_type: numeric(38, 9)  # specify precision & scale, not bare 'numeric'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write numeric column types as numeric(p, s) in contracts and casts.","Add a pre-commit lint that flags bare numeric/decimal in dbt YAML files.","Verify inferred types by inspecting the built relation after first run."],"tags":["dbt","sql","numeric-precision","warning"],"backgroundTag":"invalid-argument-format","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}