Skip to content

Commit

Permalink
Added integration test and fixed parser for trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben committed Nov 5, 2024
1 parent ccbab69 commit 59f4dbb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ constexpr parser jvm_option_parser(
>= [] () {return tJvmOptions();},
text(option_element)
>= [](auto&& e) { return to_options(std::move(e)); },
text(text, whitespaces)
>= [](auto&& ob, skip) { return std::move(ob); },
text(text, whitespaces, option_element)
>= [](auto&& ob, skip, auto&& e) { return add_option(std::move(e), std::move(ob)); },
option_element(not_separator)
Expand Down
20 changes: 20 additions & 0 deletions test_container/tests/test/java/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,26 @@ class TEST_JVM_OPT_INVALID_STACK_SIZE {
with self.assertRaisesRegex(Exception, 'unknown error'):
rows = self.query('SELECT test_jvm_opt_invalid_stack_size() FROM dual')

@useData([("-Dmyoption=Hello\ World", "Hello World"), ("-Dmyoption=\"Hello\ World\"", "\"Hello World\""),
("-Dmyoption=Hello\\tWorld", "Hello\tWorld"), ("-Dmyoption=Hello\\vWorld", "Hello\vWorld"),
("-Dmyoption=Hello\\\\World", "Hello\\World"), ("-Dmyoption=Hello\\fWorld", "Hello\fWorld"),
("-Dmyoption=Hello\ World\\t\\t ", "Hello World\t\t")])
def test_jvm_opt_escape_sequence(self, jvm_option_value, expected_return_value):
self.query(udf.fixindent('''
CREATE OR REPLACE java SCALAR SCRIPT
test_jvm_opt_with_escape()
RETURNS VARCHAR(10000) AS
%env SCRIPT_OPTIONS_PARSER_VERSION=2;
%jvmoption ''' + jvm_option_value + ''';
class TEST_JVM_OPT_WITH_ESCAPE {
static String run(ExaMetadata exa, ExaIterator ctx) throws Exception {
return System.getProperty("myoption");
}
}
'''))
self.assertRowsEqual([(expected_return_value,)],
self.query('''SELECT test_jvm_opt_with_escape()'''))


class JavaScriptClass(udf.TestCase):

Expand Down

0 comments on commit 59f4dbb

Please sign in to comment.