Skip to content
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 @@ -483,3 +483,7 @@ COMMENT
{ $channel=HIDDEN; }
;

/* Prevent that the lexer swallows unknown characters. */
ANY
:.
;
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ case class ASTNode(
override val origin: Origin = Origin(Some(line), Some(positionInLine))

/** Source text. */
lazy val source: String = stream.toString(startIndex, stopIndex)
lazy val source: String = stream.toOriginalString(startIndex, stopIndex)

/** Get the source text that remains after this token. */
lazy val remainder: String = {
stream.fill()
stream.toString(stopIndex + 1, stream.size() - 1).trim()
stream.toOriginalString(stopIndex + 1, stream.size() - 1).trim()
}

def text: String = token.getText
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.catalyst.parser

import org.apache.spark.SparkFunSuite

class ASTNodeSuite extends SparkFunSuite {
test("SPARK-13157 - remainder must return all input chars") {
val inputs = Seq(
("add jar", "file:///tmp/ab/TestUDTF.jar"),
("add jar", "file:///tmp/a@b/TestUDTF.jar"),
("add jar", "c:\\windows32\\TestUDTF.jar"),
("add jar", "some \nbad\t\tfile\r\n.\njar"),
("ADD JAR", "@*#&@(!#@$^*!@^@#(*!@#"),
("SET", "foo=bar"),
("SET", "foo*)(@#^*@&!#^=bar")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add test cases where the remainder part contains whitespace characters?

inputs.foreach {
case (command, arguments) =>
val node = ParseDriver.parsePlan(s"$command $arguments", null)
assert(node.remainder === arguments)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest {
}
}

// TODO: enable this
ignore("SPARK-11595 ADD JAR with input path having URL scheme") {
test("SPARK-11595 ADD JAR with input path having URL scheme") {
withJdbcStatement { statement =>
val jarPath = "../hive/src/test/resources/TestUDTF.jar"
val jarURL = s"file://${System.getProperty("user.dir")}/$jarPath"
Expand Down Expand Up @@ -547,8 +546,7 @@ class SingleSessionSuite extends HiveThriftJdbcTest {
override protected def extraConf: Seq[String] =
"--conf spark.sql.hive.thriftServer.singleSession=true" :: Nil

// TODO: enable this
ignore("test single session") {
test("test single session") {
withMultipleConnectionJdbcStatement(
{ statement =>
val jarPath = "../hive/src/test/resources/TestUDTF.jar"
Expand Down