当前位置: 首页>>代码示例>>Python>>正文


Python ImpalaShell.get_result方法代码示例

本文整理汇总了Python中util.ImpalaShell.get_result方法的典型用法代码示例。如果您正苦于以下问题:Python ImpalaShell.get_result方法的具体用法?Python ImpalaShell.get_result怎么用?Python ImpalaShell.get_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.ImpalaShell的用法示例。


在下文中一共展示了ImpalaShell.get_result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_malformed_query

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_malformed_query(self):
   """Test the handling of malformed query without closing quotation"""
   shell = ImpalaShell()
   query = "with v as (select 1) \nselect foo('\\\\'), ('bar \n;"
   shell.send_cmd(query)
   result = shell.get_result()
   assert "ERROR: ParseException: Unmatched string literal" in result.stderr
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:9,代码来源:test_shell_interactive.py

示例2: test_multiline_queries_in_history

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def test_multiline_queries_in_history(self, tmp_history_file):
    """Test to ensure that multiline queries with comments are preserved in history

    Ensure that multiline queries are preserved when they're read back from history.
    Additionally, also test that comments are preserved.
    """
    # readline gets its input from tty, so using stdin does not work.
    child_proc = pexpect.spawn(SHELL_CMD)
    # List of (input query, expected text in output).
    # The expected output is usually the same as the input with a number prefix, except
    # where the shell strips newlines before a semicolon.
    queries = [
        ("select\n1;--comment", "[1]: select\n1;--comment"),
        ("select 1 --comment\n;", "[2]: select 1 --comment;"),
        ("select 1 --comment\n\n\n;", "[3]: select 1 --comment;"),
        ("select /*comment*/\n1;", "[4]: select /*comment*/\n1;"),
        ("select\n/*comm\nent*/\n1;", "[5]: select\n/*comm\nent*/\n1;")]
    for query, _ in queries:
      child_proc.expect(PROMPT_REGEX)
      child_proc.sendline(query)
      child_proc.expect("Fetched 1 row\(s\) in [0-9]+\.?[0-9]*s")
    child_proc.expect(PROMPT_REGEX)
    child_proc.sendline('quit;')
    p = ImpalaShell()
    p.send_cmd('history')
    result = p.get_result()
    for _, history_entry in queries:
      assert history_entry in result.stderr, "'%s' not in '%s'" % (history_entry,
                                                                   result.stderr)
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:31,代码来源:test_shell_interactive.py

示例3: test_cancellation

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def test_cancellation(self):
    impalad = ImpaladService(socket.getfqdn())
    assert impalad.wait_for_num_in_flight_queries(0)
    command = "select sleep(10000);"
    p = ImpalaShell()
    p.send_cmd(command)
    sleep(3)
    os.kill(p.pid(), signal.SIGINT)
    result = p.get_result()
    assert "Cancelled" not in result.stderr
    assert impalad.wait_for_num_in_flight_queries(0)

    p = ImpalaShell()
    sleep(3)
    os.kill(p.pid(), signal.SIGINT)
    result = p.get_result()
    assert "^C" in result.stderr
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:19,代码来源:test_shell_interactive.py

示例4: test_change_delimiter

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_change_delimiter(self):
   """Test change output delimiter if delimited mode is enabled"""
   p = ImpalaShell()
   p.send_cmd("use tpch")
   p.send_cmd("set write_delimited=true")
   p.send_cmd("set delimiter=,")
   p.send_cmd("select * from nation")
   result = p.get_result()
   assert "21,VIETNAM,2" in result.stdout
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:11,代码来源:test_shell_interactive.py

示例5: test_cancellation

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def test_cancellation(self):
    """Test cancellation (Ctrl+C event)."""
    args = '-q "select sleep(10000)"'
    p = ImpalaShell(args)
    sleep(3)
    os.kill(p.pid(), signal.SIGINT)
    result = p.get_result()

    assert "Cancelling Query" in result.stderr, result.stderr
开发者ID:cchanning,项目名称:incubator-impala,代码行数:11,代码来源:test_shell_commandline.py

示例6: test_write_delimited

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_write_delimited(self):
   """Test output rows in delimited mode"""
   p = ImpalaShell()
   p.send_cmd("use tpch")
   p.send_cmd("set write_delimited=true")
   p.send_cmd("select * from nation")
   result = p.get_result()
   assert "+----------------+" not in result.stdout
   assert "21\tVIETNAM\t2" in result.stdout
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:11,代码来源:test_shell_interactive.py

示例7: test_cancellation

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_cancellation(self, vector):
   """Test cancellation (Ctrl+C event). Run a query that sleeps 10ms per row so will run
   for 110s if not cancelled, but will detect cancellation quickly because of the small
   batch size."""
   query = "set num_nodes=1; set mt_dop=1; set batch_size=1; \
            select sleep(10) from functional_parquet.alltypesagg"
   p = ImpalaShell(vector, ['-q', query])
   p.wait_for_query_start()
   os.kill(p.pid(), signal.SIGINT)
   result = p.get_result()
   assert "Cancelling Query" in result.stderr, result.stderr
开发者ID:apache,项目名称:incubator-impala,代码行数:13,代码来源:test_shell_commandline.py

示例8: test_with_clause

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_with_clause(self):
   # IMPALA-7939: Fix issue where CTE that contains "insert", "upsert", "update", or
   # "delete" is categorized as a DML statement.
   for keyword in ["insert", "upsert", "update", "delete", "\\'insert\\'",
                   "\\'upsert\\'", "\\'update\\'", "\\'delete\\'"]:
     p = ImpalaShell()
     p.send_cmd("with foo as "
                "(select * from functional.alltypestiny where string_col='%s') "
                "select * from foo limit 1" % keyword)
     result = p.get_result()
     assert "Fetched 0 row" in result.stderr
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:13,代码来源:test_shell_interactive.py

示例9: test_compute_stats_with_live_progress_options

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_compute_stats_with_live_progress_options(self):
   """Test that setting LIVE_PROGRESS options won't cause COMPUTE STATS query fail"""
   p = ImpalaShell()
   p.send_cmd("set live_progress=True")
   p.send_cmd("set live_summary=True")
   p.send_cmd('create table test_live_progress_option(col int);')
   try:
     p.send_cmd('compute stats test_live_progress_option;')
   finally:
     p.send_cmd('drop table if exists test_live_progress_option;')
   result = p.get_result()
   assert "Updated 1 partition(s) and 1 column(s)" in result.stdout
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:14,代码来源:test_shell_interactive.py

示例10: run_and_verify_query_cancellation_test

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def run_and_verify_query_cancellation_test(self, vector, stmt, cancel_at_state):
    """Starts the execution of the received query, waits until the query
    execution in fact starts and then cancels it. Expects the query
    cancellation to succeed."""
    p = ImpalaShell(vector, ['-q', stmt])

    self.wait_for_query_state(vector, stmt, cancel_at_state)

    os.kill(p.pid(), signal.SIGINT)
    result = p.get_result()
    assert "Cancelling Query" in result.stderr
    assert "Invalid query handle" not in result.stderr
开发者ID:apache,项目名称:incubator-impala,代码行数:14,代码来源:test_shell_commandline.py

示例11: test_print_to_file

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_print_to_file(self):
   """Test print to output file and unset"""
   # test print to file
   p1 = ImpalaShell()
   p1.send_cmd("use tpch")
   local_file = NamedTemporaryFile(delete=True)
   p1.send_cmd("set output_file=%s" % local_file.name)
   p1.send_cmd("select * from nation")
   result = p1.get_result()
   assert "VIETNAM" not in result.stdout
   with open(local_file.name, "r") as fi:
     # check if the results were written to the file successfully
     result = fi.read()
     assert "VIETNAM" in result
   # test unset to print back to stdout
   p2 = ImpalaShell()
   p2.send_cmd("use tpch")
   p2.send_cmd("set output_file=%s" % local_file.name)
   p2.send_cmd("unset output_file")
   p2.send_cmd("select * from nation")
   result = p2.get_result()
   assert "VIETNAM" in result.stdout
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:24,代码来源:test_shell_interactive.py

示例12: test_compute_stats_with_live_progress_options

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
 def test_compute_stats_with_live_progress_options(self, vector, unique_database):
   """Test that setting LIVE_PROGRESS options won't cause COMPUTE STATS query fail"""
   p = ImpalaShell(vector)
   p.send_cmd("set live_progress=True")
   p.send_cmd("set live_summary=True")
   table = "{0}.live_progress_option".format(unique_database)
   p.send_cmd('create table {0}(col int);'.format(table))
   try:
     p.send_cmd('compute stats {0};'.format(table))
   finally:
     p.send_cmd('drop table if exists {0};'.format(table))
   result = p.get_result()
   assert "Updated 1 partition(s) and 1 column(s)" in result.stdout
开发者ID:apache,项目名称:incubator-impala,代码行数:15,代码来源:test_shell_interactive.py

示例13: run_impala_shell_interactive

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
def run_impala_shell_interactive(input_lines, shell_args=None):
  """Runs a command in the Impala shell interactively."""
  # if argument "input_lines" is a string, makes it into a list
  if type(input_lines) is str:
    input_lines = [input_lines]
  # workaround to make Popen environment 'utf-8' compatible
  # since piping defaults to ascii
  my_env = os.environ
  my_env['PYTHONIOENCODING'] = 'utf-8'
  p = ImpalaShell(shell_args, env=my_env)
  for line in input_lines:
    p.send_cmd(line)
  return p.get_result()
开发者ID:mbrukman,项目名称:apache-impala,代码行数:15,代码来源:test_shell_interactive.py

示例14: test_queries_closed

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def test_queries_closed(self, vector):
    """Regression test for IMPALA-897."""
    args = ['-f', '{0}/test_close_queries.sql'.format(QUERY_FILE_PATH), '--quiet', '-B']
    # Execute the shell command async
    p = ImpalaShell(vector, args)

    impalad_service = ImpaladService(get_impalad_host_port(vector).split(':')[0])
    # The last query in the test SQL script will sleep for 10 seconds, so sleep
    # here for 5 seconds and verify the number of in-flight queries is 1.
    sleep(5)
    assert 1 == impalad_service.get_num_in_flight_queries()
    assert p.get_result().rc == 0
    assert 0 == impalad_service.get_num_in_flight_queries()
开发者ID:apache,项目名称:incubator-impala,代码行数:15,代码来源:test_shell_commandline.py

示例15: test_timezone_validation

# 需要导入模块: from util import ImpalaShell [as 别名]
# 或者: from util.ImpalaShell import get_result [as 别名]
  def test_timezone_validation(self):
    """Test that query option TIMEZONE is validated when executing a query.

       Query options are not sent to the coordinator immediately, so the error checking
       will only happen when running a query.
    """
    p = ImpalaShell()
    p.send_cmd('set timezone=BLA;')
    p.send_cmd('select 1;')
    results = p.get_result()
    assert "Fetched 1 row" not in results.stderr
    assert "ERROR: Errors parsing query options" in results.stderr
    assert "Invalid timezone name 'BLA'" in results.stderr
开发者ID:timarmstrong,项目名称:incubator-impala,代码行数:15,代码来源:test_shell_interactive.py


注:本文中的util.ImpalaShell.get_result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。