Example #1
0
File: tests.py Project: gigfork/hue
  def test_sync_query_exec(self):
    # Execute Query Synchronously, set fetch size and fetch results
    # verify the size of resultset,
    QUERY = """
      SELECT foo FROM test;
    """

    query_msg = BeeswaxService.Query()
    query_msg.query = """
      SELECT foo FROM test
    """
    query_msg.configuration = []
    query_msg.hadoop_user = "******"
    handle = beeswax.db_utils.db_client().executeAndWait(query_msg, "")
 
    results = beeswax.db_utils.db_client().fetch(handle, True, 5)
    row_list = list(parse_results(results.data))
    assert_equal(len(row_list), 5)

    beeswax.db_utils.db_client().close(handle)
    beeswax.db_utils.db_client().clean(handle.log_context)
Example #2
0
  def test_sync_query_exec(self):
    # Execute Query Synchronously, set fetch size and fetch results
    # verify the size of resultset,
    QUERY = """
      SELECT foo FROM test;
    """

    query_msg = BeeswaxService.Query()
    query_msg.query = """
      SELECT foo FROM test
    """
    query_msg.configuration = []
    query_msg.hadoop_user = "******"
    handle = beeswax.db_utils.db_client(get_query_server()).executeAndWait(query_msg, "")

    results = beeswax.db_utils.db_client(get_query_server()).fetch(handle, True, 5)
    row_list = list(parse_results(results.data))
    assert_equal(len(row_list), 5)

    beeswax.db_utils.db_client(get_query_server()).close(handle)
    beeswax.db_utils.db_client(get_query_server()).clean(handle.log_context)
Example #3
0
File: tests.py Project: gigfork/hue
def test_parse_results():
  data = ["foo\tbar", "baz\tboom"]
  assert_equal([["foo", "bar"], ["baz", "boom"]],
    [ x for x in parse_results(data) ])
Example #4
0
def test_parse_results():
    data = ["foo\tbar", "baz\tboom"]
    assert_equal([["foo", "bar"], ["baz", "boom"]],
                 [x for x in parse_results(data)])
Example #5
0
  download_urls = {}
  if downloadable:
    for format in common.DL_FORMATS:
      download_urls[format] = urlresolvers.reverse(download, kwargs=dict(id=str(id), format=format))

  save_form = SaveResultsForm()
  has_more = True
  last_result_len = long(last_result_len)
  if (last_result_len != 0 and len(results.data) != last_result_len) or len(results.data) == 0:
    has_more = False
  # Display the results
  return render('watch_results.mako', request, {
    'error': False,
    'query': query_history,
    # Materialize, for easier testability.
    'results': list(parse_results(results.data)),
    'last_result_len': len(results.data),
    'has_more': has_more,
    'next_row': results.start_row + len(results.data),
    'start_row': results.start_row,
    'expected_first_row': first_row,
    'columns': results.columns,
    'download_urls': download_urls,
    'log': log,
    'hadoop_jobs': _parse_out_hadoop_jobs(log),
    'query_context': context,
    'save_form': save_form,
    'can_save': query_history.owner == request.user,
  })

Example #6
0
    save_form = SaveResultsForm()
    has_more = True
    last_result_len = long(last_result_len)
    if (last_result_len != 0 and len(results.data) != last_result_len) or len(
            results.data) == 0:
        has_more = False
    # Display the results
    return render(
        'watch_results.mako',
        request,
        {
            'error': False,
            'query': query_history,
            # Materialize, for easier testability.
            'results': list(parse_results(results.data)),
            'last_result_len': len(results.data),
            'has_more': has_more,
            'next_row': results.start_row + len(results.data),
            'start_row': results.start_row,
            'expected_first_row': first_row,
            'columns': results.columns,
            'download_urls': download_urls,
            'log': log,
            'hadoop_jobs': _parse_out_hadoop_jobs(log),
            'query_context': context,
            'save_form': save_form,
            'can_save': query_history.owner == request.user,
        })