Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -22,6 +22,7 @@ import java.sql.Connection
import org.apache.spark.SparkConf
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException
import org.apache.spark.sql.execution.FilterExec
import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog
import org.apache.spark.sql.jdbc.DatabaseOnDocker
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -123,4 +124,13 @@ class PostgresIntegrationSuite extends DockerJDBCIntegrationV2Suite with V2JDBCT
)
}
}

test("SPARK-49695: Postgres fix xor push-down") {
val df = spark.sql(s"select dept, name from $catalogName.employee where dept ^ 6 = 0")
val rows = df.collect()
assert(!df.queryExecution.sparkPlan.exists(_.isInstanceOf[FilterExec]))
assert(rows.length == 1)
assert(rows(0).getInt(0) === 6)
assert(rows(0).getString(1) === "jen")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ private object PostgresDialect extends JdbcDialect with SQLConfHelper {
}
}

class PostgresSQLBuilder extends JDBCSQLBuilder {
override def visitBinaryArithmetic(name: String, l: String, r: String): String = {
l + " " + name.replace('^', '#') + " " + r
}
}

override def supportsLimit: Boolean = true

override def supportsOffset: Boolean = true
Expand Down