-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-32696][SQL][test-hive1.2][test-hadoop2.7]Get columns operation should handle interval column properly #29539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ package org.apache.spark.sql.hive.thriftserver | |
|
|
||
| import java.sql.{DatabaseMetaData, ResultSet} | ||
|
|
||
| import org.apache.spark.sql.types.{ArrayType, BinaryType, BooleanType, DecimalType, DoubleType, FloatType, IntegerType, MapType, NumericType, StringType, StructType, TimestampType} | ||
| import org.apache.spark.sql.types.{ArrayType, BinaryType, BooleanType, CalendarIntervalType, DecimalType, DoubleType, FloatType, IntegerType, MapType, NumericType, StringType, StructType, TimestampType} | ||
|
|
||
| class SparkMetadataOperationSuite extends HiveThriftJdbcTest { | ||
|
|
||
|
|
@@ -333,4 +333,31 @@ class SparkMetadataOperationSuite extends HiveThriftJdbcTest { | |
| assert(pos === 17, "all columns should have been verified") | ||
| } | ||
| } | ||
|
|
||
| test("get columns operation should handle interval column properly") { | ||
| val viewName = "view_interval" | ||
| val ddl = s"CREATE GLOBAL TEMP VIEW $viewName as select interval 1 day as i" | ||
|
|
||
| withJdbcStatement(viewName) { statement => | ||
| statement.execute(ddl) | ||
| val data = statement.getConnection.getMetaData | ||
| val rowSet = data.getColumns("", "global_temp", viewName, null) | ||
| while (rowSet.next()) { | ||
| assert(rowSet.getString("TABLE_CAT") === null) | ||
| assert(rowSet.getString("TABLE_SCHEM") === "global_temp") | ||
| assert(rowSet.getString("TABLE_NAME") === viewName) | ||
| assert(rowSet.getString("COLUMN_NAME") === "i") | ||
| assert(rowSet.getInt("DATA_TYPE") === java.sql.Types.OTHER) | ||
| assert(rowSet.getString("TYPE_NAME").equalsIgnoreCase(CalendarIntervalType.sql)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we treat it as string type, can we still report the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that all the meta operations should do nothing else but specifically describe how all the objects(database/table /columns etc) stored in the Spark system. If we change the column meta here from INTERVAL to STRING, so the column here becomes orderable and comparable?(JDBC users may guess), they may have no idea about what they are dealing with and get a completely different awareness of the meta-information comparing to those users who use spark-sql self-contained applications. |
||
| assert(rowSet.getInt("COLUMN_SIZE") === CalendarIntervalType.defaultSize) | ||
| assert(rowSet.getInt("DECIMAL_DIGITS") === 0) | ||
| assert(rowSet.getInt("NUM_PREC_RADIX") === 0) | ||
| assert(rowSet.getInt("NULLABLE") === 0) | ||
| assert(rowSet.getString("REMARKS") === "") | ||
| assert(rowSet.getInt("ORDINAL_POSITION") === 0) | ||
| assert(rowSet.getString("IS_NULLABLE") === "YES") | ||
| assert(rowSet.getString("IS_AUTO_INCREMENT") === "NO") | ||
| } | ||
| } | ||
| } | ||
| } | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can we also test an extract query of the table with calendar types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR fixes SparkGetColumnsOperation. As a meta operation, it is not related to extract-queries that executed by SparkExecuteStatementOperation. BTW, I notice that test cases for extracting interval values in VIEWS through the thrift server might be missing in the current codebase. Maybe we can make another PR to improve these, WDYT, @cloud-fan Or I can just add some UTs here https://github.com/yaooqinn/spark/blob/d24d27f1bc39e915df23d65f8fda0d83e716b308/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala#L674
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I think we should add a small check here to make sure they actually work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK to add the missing test in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thank you guys for the check~