4paradigm / 4paradigm/OpenMLDB

Fail to get table constrains of Hive tables with Spark API

Abierto
#3,072 0 comentarios 0 reacciones 1 asignado Reclamado por @tobegit3hub Ver en GitHub
batch-engine bug
Lenguaje dominante
C++
Estrellas
1.7k
Forks
331
Merge medio
12 d 12 h
PR fusionados (30 d)
1

Descripción

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
}
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
scala, spark
Área
data-engineering, databases
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.