StarRocks / dbt-starrocks

dbt-starrocks contains all of the code enabling dbt to work with StarRocks
16 stars 6 forks source link

StarRocksColumn(Column) has a bug in treating String fields #41

Closed mcgray closed 5 months ago

mcgray commented 5 months ago

SR version of Column does not override parent's string_type which means that we are using "character varying" as a type name for String fields. This type does not exist in SR.

Steps to reproduce

  1. Create any table

  2. Try to add a column to a table via:

    {{
    config(
        materialized='incremental',
        on_schema_change='append_new_columns'
    )
    }}
    select
    cast(NULL as varchar) as `atp_new`
    where false
  3. Observe logs: add column atp_new character varying(1048576)

  4. DBT run finished with error

Expected behavior

1, 2 as above Logs should show something like: add column atp_new varchar(65535)

And run should finish with success.

Versions

Core:
  - installed: 1.6.11
  - latest:    1.7.11 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - starrocks: 1.6.1 - Up to date!

Suggested fix

@classmethod
    def string_type(cls, size: int) -> str:
        return "varchar({})".format(size)
alberttwong commented 5 months ago

Can you submit a pr?