Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
szehon-ho committed Aug 10, 2023
1 parent 1b63105 commit cecb085
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,7 @@ object RelationWithOptions {
val tableIdentifier = CatalystSqlParser.parseMultipartIdentifier(
identifier.asInstanceOf[Literal].toString)
val relationOptions = ExprUtils.convertToMapData(options)
UnresolvedRelation(tableIdentifier,
new CaseInsensitiveStringMap(relationOptions.asJava))
UnresolvedRelation(tableIdentifier, new CaseInsensitiveStringMap(relationOptions.asJava))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ package org.apache.spark.sql.connector
import java.sql.Timestamp
import java.time.{Duration, LocalDate, Period}
import java.util.Locale

import scala.collection.JavaConverters._
import scala.concurrent.duration.MICROSECONDS

import org.apache.spark.{SparkException, SparkUnsupportedOperationException}
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.InternalRow
Expand Down Expand Up @@ -3299,14 +3301,13 @@ class DataSourceV2SQLSuiteV1Filter
sql(s"CREATE TABLE $t1 (id bigint, data string) USING $v2Format")
sql(s"INSERT INTO $t1 VALUES (1, 'a'), (2, 'b')")

val df = sql(s"SELECT * FROM with_options('$t1', map('foo','bar'))")
val df = sql(s"SELECT * FROM with_options('$t1', map('split-size', '5'))")
val collected = df.queryExecution.optimizedPlan.collect {
case scan: DataSourceV2ScanRelation =>
assert(scan.relation.options.get("foo") == "bar")
assert(scan.relation.options.get("split-size") == "5")
}
assert (collected.size == 1)
checkAnswer(sql(s"SELECT * FROM with_options('$t1', map('foo','bar'))"),
Seq(Row(1, "a"), Row(2, "b")))
checkAnswer(df, Seq(Row(1, "a"), Row(2, "b")))
}

// negative tests
Expand All @@ -3320,7 +3321,7 @@ class DataSourceV2SQLSuiteV1Filter
val wrongFirstArg = intercept[AnalysisException](
sql(s"SELECT * FROM with_options(foo, map('foo','bar'))"))
assert(wrongFirstArg.message.contains(
"A column or function parameter with name `foo` cannot be resolved"
"A column, variable, or function parameter with name `foo` cannot be resolved"
))

val wrongSecondArg = intercept[AnalysisException](
Expand Down

0 comments on commit cecb085

Please sign in to comment.