예제 #1
0
  def test_var_substitution(self, vector):
    args = ['--var=foo=123', '--var=BAR=456', '--delimited', '--output_delimiter= ',
            '-c', '-f', os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql')]
    result = run_impala_shell_cmd(vector, args, expect_success=True)
    assert_var_substitution(result)
    args = ['--var=foo']
    result = run_impala_shell_cmd(vector, args, expect_success=False)
    assert ("Error: Could not parse key-value \"foo\". It must follow the pattern "
             "\"KEY=VALUE\".") in result.stderr

    # IMPALA-7673: Test that variable substitution in command line can accept values
    # from other variables just like the one in interactive shell.
    result = run_impala_shell_cmd(vector, [
      '--var=msg1=1', '--var=msg2=${var:msg1}2', '--var=msg3=${var:msg1}${var:msg2}',
      '--query=select ${var:msg3}'])
    self._validate_shell_messages(result.stderr, ['112', 'Fetched 1 row(s)'],
                                  should_exist=True)

    # Test with an escaped variable.
    result = run_impala_shell_cmd(vector, ['--var=msg1=1', '--var=msg2=${var:msg1}2',
                                           '--var=msg3=\${var:msg1}${var:msg2}',
                                           "--query=select '${var:msg3}'"])
    self._validate_shell_messages(result.stderr, ['${var:msg1}12', 'Fetched 1 row(s)'],
                                  should_exist=True)

    # Referencing a non-existent variable will result in an error.
    result = run_impala_shell_cmd(vector, [
        '--var=msg1=1', '--var=msg2=${var:doesnotexist}2',
        '--var=msg3=\${var:msg1}${var:msg2}', "--query=select '${var:msg3}'"],
        expect_success=False)
    self._validate_shell_messages(result.stderr,
                                  ['Error: Unknown variable DOESNOTEXIST',
                                   'Could not execute command: select \'${var:msg3}\''],
                                  should_exist=True)
  def test_var_substitution(self):
    args = '--var=foo=123 --var=BAR=456 --delimited --output_delimiter=" " -c -f %s' \
           % (os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql'))
    result = run_impala_shell_cmd(args, expect_success=True)
    assert_var_substitution(result)
    args = '--var=foo'
    result = run_impala_shell_cmd(args, expect_success=False)
    assert ("Error: Could not parse key-value \"foo\". It must follow the pattern "
             "\"KEY=VALUE\".") in result.stderr

    # IMPALA-7673: Test that variable substitution in command line can accept values
    # from other variables just like the one in interactive shell.
    result = run_impala_shell_cmd('--var="msg1=1" --var="msg2=${var:msg1}2" '
                                  '--var="msg3=${var:msg1}${var:msg2}" '
                                  '--query="select ${var:msg3}"')
    self._validate_shell_messages(result.stderr, ['112', 'Fetched 1 row(s)'],
                                  should_exist=True)

    # Test with an escaped variable.
    result = run_impala_shell_cmd('--var="msg1=1" --var="msg2=${var:msg1}2" '
                                  '--var="msg3=\${var:msg1}${var:msg2}" '
                                  '--query="select \'${var:msg3}\'"')
    self._validate_shell_messages(result.stderr, ['${var:msg1}12', 'Fetched 1 row(s)'],
                                  should_exist=True)

    # Referencing a non-existent variable will result in an error.
    result = run_impala_shell_cmd('--var="msg1=1" --var="msg2=${var:doesnotexist}2" '
                                  '--var="msg3=\${var:msg1}${var:msg2}" '
                                  '--query="select \'${var:msg3}\'"',
                                  expect_success=False)
    self._validate_shell_messages(result.stderr,
                                  ['Error: Unknown variable DOESNOTEXIST',
                                   'Could not execute command: select \'${var:msg3}\''],
                                  should_exist=True)
예제 #3
0
 def test_var_substitution(self, vector):
     cmds = open(os.path.join(QUERY_FILE_PATH,
                              'test_var_substitution.sql')).read()
     args = [
         "--var=foo=123", "--var=BAR=456", "--delimited",
         "--output_delimiter= "
     ]
     result = run_impala_shell_interactive(vector, cmds, shell_args=args)
     assert_var_substitution(result)
예제 #4
0
 def test_var_substitution(self):
   args = '--var=foo=123 --var=BAR=456 --delimited --output_delimiter=" " -c -f %s' \
          % (os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql'))
   result = run_impala_shell_cmd(args, expect_success=True)
   assert_var_substitution(result)
   args = '--var=foo'
   result = run_impala_shell_cmd(args, expect_success=False)
   assert ("Error: Could not parse key-value \"foo\". It must follow the pattern "
            "\"KEY=VALUE\".") in result.stderr
예제 #5
0
 def test_var_substitution(self):
     cmds = open(os.path.join(QUERY_FILE_PATH,
                              'test_var_substitution.sql')).read()
     args = '''--var=foo=123 --var=BAR=456 --delimited "--output_delimiter= " '''
     result = run_impala_shell_interactive(cmds, shell_args=args)
     assert_var_substitution(result)
 def test_var_substitution(self):
   cmds = open(os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql')).read()
   args = '''--var=foo=123 --var=BAR=456 --delimited "--output_delimiter= " '''
   result = run_impala_shell_interactive(cmds, shell_args=args)
   assert_var_substitution(result)
 def test_var_substitution(self, vector):
   cmds = open(os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql')).read()
   args = ["--var=foo=123", "--var=BAR=456", "--delimited", "--output_delimiter= "]
   result = run_impala_shell_interactive(vector, cmds, shell_args=args)
   assert_var_substitution(result)
 def test_var_substitution(self):
   args = '--var=foo=123 --var=BAR=456 --delimited --output_delimiter=" " -c -f %s' \
          % (os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql'))
   result = run_impala_shell_cmd(args, expect_success=True)
   assert_var_substitution(result)
 def test_var_substitution(self):
     args = '--var=foo=123 --var=BAR=456 --delimited --output_delimiter=" " -c -f %s' \
            % (os.path.join(QUERY_FILE_PATH, 'test_var_substitution.sql'))
     result = run_impala_shell_cmd(args, expect_success=True)
     assert_var_substitution(result)