4paradigm / 4paradigm/OpenMLDB

Fail to get table constrains of Hive tables with Spark API

Đang mở
#3,072 0 bình luận 0 reaction 1 người được giao Được @tobegit3hub nhận Xem trên GitHub
batch-engine bug
Ngôn ngữ chính
C++
Star
1.7k
Fork
331
Merge trung bình
12 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

Now we can not get table constrains like `not null` with Spark API. It may be the bug of Spark.

Here is the process to re-produce the issue.

We can create the table with constrains with hive.

```
create table notnull_col_table2 (col1 int not null, col2 int);
```

But we may not get the not null constrains with Spark API.

```
def main(argv: Array[String]): Unit = {

val spark = SparkSession.builder()
.master("local")
.config("spark.hadoop.hive.metastore.uris", "thrift://localhost:9083")
.config("spark.sql.catalogImplementation", "hive")
.getOrCreate()

val df = spark.table("db1.notnull_col_table2")

val schema = df.schema
println(schema) # StructType(StructField(col1,IntegerType,true),StructField(col2,IntegerType,true))

val col1_schema = schema.fields(0)
println(col1_schema.nullable) # true
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

The issue is about Spark API not retrieving NOT NULL constraints from Hive tables. Start by examining how Spark's Hive integration fetches table metadata, particularly in the Spark SQL Hive client code. Look for where column nullability is determined. The test involves creating a Hive table with a NOT NULL column and checking the schema via spark.table. 'Done' means the nullable field in the schema correctly shows false for the constrained column.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
scala, spark
Lĩnh vực
data-engineering, databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.