1.[SPARK-39936][SQL] Store schema in properties for Spark Views,spark视图保存到hive metastore时未清空tableschema导致解析失败
Hive DataType解析器主要发生在Hive的元数据存储(Hive Metastore)阶段。当Hive创建表或解析表结构时,Hive会使用DataType解析器来解析表中定义的数据类型。这个解析器会尝试解析和转换表的列、字段和分区的数据类型、长度、约束等信息。它会确保表定义与Hive的数据类型系统相匹配,并正确解析表结构,从而能够正确地进行数据的存储和查询。如果在解析过程中出现格式错误或不受支持的数据类型,解析器会抛出异常并中断解析过程。在这个阶段,Hive DataType解析器负责将用户定义的数据类型转换为Hive支持的数据类型,并确保数据的一致性和正确性。
[SPARK-39936][SQL] 在Spark视图中存储模式属性
这个pull request提出了什么样的改变?
通常我们将tableSchema存储在table属性中,而不是作为实际模式。我们通常这样做是因为它有助于绕过一些Hive-Metastore问题,包括与SparkSQLDataType解析器的解析问题。
然而,问题在于我们没有清空Spark视图的tableSchema(Spark视图本来就与Hive不兼容)。因此,Hive DataType解析器会尝试解析模式并导致错误。解决方法是在将Spark视图保存到Hive Metastore时清空tableSchema。
这修复了以下错误:
-- this works since we use backticks in `date-of-creation`
create table table_with_hyphen (f array<struct<validColumnTypeName:string>>) using parquet;
-- this should work since we use backticks in `date-of-creation` but will break without this bugfix
create or replace view view_with_hyphen as select f from table_with_hyphen;
2.[SPARK-40002][SQL] Don't push down limit through window using ntile,将nitle函数应用于limit的结果将会导致错误的结果
[
这个拉取请求提议的更改是更改"LimitPushDownThroughWindow",使其不再支持通过ntile函数将limit下推到窗口。
需要进行这些更改的原因是在无分区窗口中,目前ntile函数应用于limit的结果。这种行为会导致与Spark 3.1.3、Hive 2.3.9和PrestoDB 0.268产生冲突的结果。
举个例子:
假设有以下数据
Assume this data:
```
create table t1 stored as parquet as
select *
from range(101);
```
Also assume this query:
```
select id, ntile(10) over (order by id) as nt
from t1
limit 10;
```
With Spark 3.2.2, Spark 3.3.0, and master, the limit is applied before the ntile function:
```
+---+---+
|id |nt |
+---+---+
|0 |1 |
|1 |2 |
|2 |3 |
|3 |4 |
|4 |5 |
|5 |6 |
|6 |7 |
|7 |8 |
|8 |9 |
|9 |10 |
+---+---+
```
With Spark 3.1.3, and Hive 2.3.9, and Prestodb 0.268, the limit is applied _after_ ntile.
Spark 3.1.3:
```
+---+---+
|id |nt |
+---+---+
|0 |1 |
|1 |1 |
|2 |1 |
|3 |1 |
|4 |1 |
|5 |1 |
|6 |1 |
|7 |1 |
|8 |1 |
|9 |1 |
+---+---+
```
Hive 2.3.9:
```
+-----+-----+
| id | nt |
+-----+-----+
| 0 | 1 |
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 1 |
| 7 | 1 |
| 8 | 1 |
| 9 | 1 |
+-----+-----+
10 rows selected (1.72 seconds)
```
Prestodb 0.268:
```
id | nt
----+----
0 | 1
1 | 1
2 | 1
3 | 1
4 | 1
5 | 1
6 | 1
7 | 1
8 | 1
9 | 1
(10 rows)
```
3. [SPARK-40963][SQL] Set nullable correctly in project created by ExtractGenerator,可能会导致错误的结果以及空指针问题