ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
3.83k stars 532 forks source link

type mismatch during creation table with default values #2034

Closed dcherednik closed 4 months ago

dcherednik commented 7 months ago

local=> CREATE TABLE alert_configuration ( local(> id integer NOT NULL, local(> alertmanager_configuration text NOT NULL, local(> configuration_version character varying(3) NOT NULL, local(> created_at integer NOT NULL, local(> "default" boolean DEFAULT false NOT NULL, local(> org_id bigint DEFAULT 0 NOT NULL, local(> configuration_hash character varying(32) DEFAULT 'not-yet-calculated'::character varying NOT NULL, local(> PRIMARY KEY (id) local(> ); Status: GENERIC_ERROR Issues:

: Error: Type annotation, code: 1030
:1:1: Error: At function: KiCreateTable!
:1:1: Error: Default expr org_id type mismatch, expected: pgint8, actual: pgint4 if write explicit cast works fine local=> CREATE TABLE alert_configuration ( id integer NOT NULL, alertmanager_configuration text NOT NULL, configuration_version character varying(3) NOT NULL, created_at integer NOT NULL, "default" boolean DEFAULT false NOT NULL, org_id bigint DEFAULT CAST(0 AS int8) NOT NULL, configuration_hash character varying(32) DEFAULT 'not-yet-calculated'::character varying NOT NULL, PRIMARY KEY (id) ); CREATE TABLE
dcherednik commented 5 months ago

"Default expr Value2 type mismatch, expected: Int64, actual: Int32"

in case of " Int64 NOT NULL DEFAULT 1" during table creation

gridnevvvit commented 4 months ago

fixed in https://github.com/ydb-platform/ydb/pull/4085 and in https://github.com/ydb-platform/ydb/pull/4046