StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
9.07k stars 1.82k forks source link

StarRocks discards the NOT NULL constraint of the external table when constructing the full schema, leading to the failure of view creation #48181

Open elon-X opened 4 months ago

elon-X commented 4 months ago

When I try to build an asynchronous partitioned view based on an external table (paimon table / hive table) with a partition field (string type), I encounter an error: ERROR 1064 (HY000): List partition columns must not be nullable in Materialized view for now, which causes the asynchronous view construction to fail.

Root Cause:

1.StarRocks checks whether partition fields have the NOT NULL constraint when building asynchronous views. 339466daabc75fbca1853dd9fb14efc4

2.Upon checking the schema of the paimon table, the partition field does have the NOT NULL constraint. 0bccdd8cef3d4148ea0b12e83c9ec25b

3.When StarRocks constructs the full schema, it forces all fields to be nullable. This results in an exception being thrown when constructing the view f051bf9209752f1710fc9d1071bd0812

Additionally, this issue can be observed by using DESC tableA; or SHOW CREATE TABLE tableA;

Steps to reproduce the behavior (Required)

  1. desc tableA; // show create table tableA;

Expected behavior (Required)

image

Real behavior (Required)

image image

StarRocks version (Required)

StarRocks-3.3.0

LiShuMing commented 4 months ago

Materialized view support list partition with nullable column will be supported in 3.3.1/3.3.2.

elon-X commented 4 months ago

@LiShuMing I checked the code in the main branch, and when constructing the fullSchema, all fields are still set to isAllowNull = true. The isNullable field in DataType can obtain the non-null constraints from the original schema, so we can set this value instead of hardcoding it to true. This will cause the table schema information displayed by different clients to be inconsistent, which will confuse users. WDYT?

Column column = new Column(fieldName, fieldType, type.isNullable(), field.description());

LiShuMing commented 3 months ago

@elon-X Yep, you are right. But for external tables, not null constraint maybe exactly right since its strong schema evolution.

You can try StarRocks v3.3.2 again, this issue should be fixed already.