Skip to content
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

[SPARK-45449][SQL] Cache Invalidation Issue with JDBC Table #43258

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ class JDBCOptions(
.get(JDBC_PREFER_TIMESTAMP_NTZ)
.map(_.toBoolean)
.getOrElse(SQLConf.get.timestampType == TimestampNTZType)

override def hashCode: Int = this.parameters.hashCode()

override def equals(other: Any): Boolean = other match {
case otherOption: JDBCOptions =>
otherOption.parameters.equals(this.parameters)
case _ => false
}
}

class JdbcOptionsInWrite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.apache.spark.sql.{AnalysisException, QueryTest, Row}
import org.apache.spark.sql.catalyst.analysis.{NoSuchNamespaceException, TableAlreadyExistsException}
import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.catalyst.util.CharVarcharUtils
import org.apache.spark.sql.execution.columnar.InMemoryTableScanExec
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -512,4 +513,18 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession {
assert(t.schema === replaced)
}
}

test("SPARK-45449: Cache Invalidation Issue with JDBC Table") {
withTable("h2.test.cache_t") {
withConnection { conn =>
conn.prepareStatement(
"""CREATE TABLE "test"."cache_t" (id decimal(25) PRIMARY KEY NOT NULL,
|name TEXT(32) NOT NULL)""".stripMargin).executeUpdate()
}
sql("INSERT OVERWRITE h2.test.cache_t SELECT 1 AS id, 'a' AS name")
sql("CACHE TABLE t1 SELECT id, name FROM h2.test.cache_t")
val plan = sql("select * from t1").queryExecution.sparkPlan
assert(plan.isInstanceOf[InMemoryTableScanExec])
}
}
}