Skip to content

Commit

Permalink
Merge 3ae2748 into c65cc12
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcclp committed Jul 26, 2019
2 parents c65cc12 + 3ae2748 commit d88633c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Expand Up @@ -788,7 +788,20 @@ class UpdateCarbonTableTestCase extends QueryTest with BeforeAndAfterAll {
sql("""drop table if exists iud.dest33_part""")
}

override def afterAll {
test("[CARBONDATA-3477] deal line break chars correctly after 'select' in 'update ... select columns' sql") {
sql("""drop table if exists iud.dest11""").show
sql("""create table iud.dest11 (c1 string,c2 int,c3 string,c5 string) STORED BY 'org.apache.carbondata.format'""")
sql(s"""LOAD DATA LOCAL INPATH '$resourcesPath/IUD/dest.csv' INTO table iud.dest11""")
sql("""update iud.dest11 d set (d.c3, d.c5 ) = (select
s.c33,s.c55 from iud.source2 s where d.c1 = s.c11) where 1 = 1""").show()
checkAnswer(
sql("""select c3,c5 from iud.dest11"""),
Seq(Row("cc","ccc"), Row("dd","ddd"),Row("ee","eee"), Row("MGM","Disco"),Row("RGK","Music"))
)
sql("""drop table iud.dest11""").show
}

override def afterAll {
sql("use default")
sql("drop database if exists iud cascade")
CarbonProperties.getInstance()
Expand Down
Expand Up @@ -284,8 +284,9 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser {
("=" ~> restInput) <~ opt(";") ^^ {
case tab ~ columns ~ rest =>
val (sel, where) = splitQuery(rest)
val selectPattern = """^\s*select\s+""".r
val (selectStmt, relation) =
if (!sel.toLowerCase.startsWith("select ")) {
if (!selectPattern.findFirstIn(sel.toLowerCase).isDefined) {
if (sel.trim.isEmpty) {
sys.error("At least one source column has to be specified ")
}
Expand Down

0 comments on commit d88633c

Please sign in to comment.