import pytest
from copy import copy
from tests.common.test_vector import TestDimension
from tests.common.impala_test_suite import ImpalaTestSuite, ALL_NODES_ONLY

# We use very small scan ranges to exercise corner cases in the HDFS scanner more
# thoroughly. In particular, it will exercise:
# 1. scan range with no tuple
# 2. tuple that span across multiple scan ranges
MAX_SCAN_RANGE_LENGTHS = [1, 2, 5]

class TestScanRangeLengths(ImpalaTestSuite):
  @classmethod
  def get_workload(cls):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestScanRangeLengths, cls).add_test_dimensions()
    cls.TestMatrix.add_dimension(
        TestDimension('max_scan_range_length', *MAX_SCAN_RANGE_LENGTHS))

  def test_scan_ranges(self, vector):
    if vector.get_value('table_format').file_format != 'text':
      pytest.xfail(reason='IMP-636')
    elif vector.get_value('table_format').compression_codec != 'none':
      pytest.xfail(reason='IMPALA-122')

    vector.get_value('exec_option')['max_scan_range_length'] =\
        vector.get_value('max_scan_range_length')
    self.run_test_case('QueryTest/hdfs-tiny-scan', vector)

import pytest
from copy import copy
from tests.common.test_vector import TestDimension
from tests.common.impala_test_suite import ImpalaTestSuite, ALL_NODES_ONLY

# We use very small scan ranges to exercise corner cases in the HDFS scanner more
# thoroughly. In particular, it will exercise:
# 1. scan range with no tuple
# 2. tuple that span across multiple scan ranges
MAX_SCAN_RANGE_LENGTHS = [1, 2, 5]

class TestScanRangeLengths(ImpalaTestSuite):
  @classmethod
  def get_workload(cls):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestScanRangeLengths, cls).add_test_dimensions()
    cls.TestMatrix.add_dimension(
        TestDimension('max_scan_range_length', *MAX_SCAN_RANGE_LENGTHS))

  def test_scan_ranges(self, vector):
    if vector.get_value('table_format').file_format != 'text':
      pytest.xfail(reason='IMP-636')

    vector.get_value('exec_option')['max_scan_range_length'] =\
        vector.get_value('max_scan_range_length')
    self.run_test_case('QueryTest/hdfs-tiny-scan', vector)

Fix IMPALA-122: Lzo scanner with small scan ranges.
Fix IMPALA-122: Lzo scanner with small scan ranges.

Change-Id: I5226fd1a1aa368f5b291b78ad371363057ef574e
Reviewed-on: http://gerrit.ent.cloudera.com:8080/140
Reviewed-by: Skye Wanderman-Milne <6d4b168ab637b0a20cc9dbf96abb2537f372f946@cloudera.com>
Reviewed-by: Nong Li <99a5e5f8f5911755b88e0b536d46aafa102bed41@cloudera.com>
Tested-by: Nong Li <99a5e5f8f5911755b88e0b536d46aafa102bed41@cloudera.com>

  import pytest
  from copy import copy
  from tests.common.test_vector import TestDimension
  from tests.common.impala_test_suite import ImpalaTestSuite, ALL_NODES_ONLY
  
  # We use very small scan ranges to exercise corner cases in the HDFS scanner more
  # thoroughly. In particular, it will exercise:
  # 1. scan range with no tuple
  # 2. tuple that span across multiple scan ranges
  MAX_SCAN_RANGE_LENGTHS = [1, 2, 5]
  
  class TestScanRangeLengths(ImpalaTestSuite):
    @classmethod
    def get_workload(cls):
      return 'functional-query'
  
    @classmethod
    def add_test_dimensions(cls):
      super(TestScanRangeLengths, cls).add_test_dimensions()
      cls.TestMatrix.add_dimension(
          TestDimension('max_scan_range_length', *MAX_SCAN_RANGE_LENGTHS))
  
    def test_scan_ranges(self, vector):
      if vector.get_value('table_format').file_format != 'text':
        pytest.xfail(reason='IMP-636')
-     elif vector.get_value('table_format').compression_codec != 'none':
-       pytest.xfail(reason='IMPALA-122')
  
      vector.get_value('exec_option')['max_scan_range_length'] =\
          vector.get_value('max_scan_range_length')
      self.run_test_case('QueryTest/hdfs-tiny-scan', vector)
  
Fix IMPALA-122: Lzo scanner with small scan ranges.
## Code Before:
import pytest
from copy import copy
from tests.common.test_vector import TestDimension
from tests.common.impala_test_suite import ImpalaTestSuite, ALL_NODES_ONLY

# We use very small scan ranges to exercise corner cases in the HDFS scanner more
# thoroughly. In particular, it will exercise:
# 1. scan range with no tuple
# 2. tuple that span across multiple scan ranges
MAX_SCAN_RANGE_LENGTHS = [1, 2, 5]

class TestScanRangeLengths(ImpalaTestSuite):
  @classmethod
  def get_workload(cls):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestScanRangeLengths, cls).add_test_dimensions()
    cls.TestMatrix.add_dimension(
        TestDimension('max_scan_range_length', *MAX_SCAN_RANGE_LENGTHS))

  def test_scan_ranges(self, vector):
    if vector.get_value('table_format').file_format != 'text':
      pytest.xfail(reason='IMP-636')
    elif vector.get_value('table_format').compression_codec != 'none':
      pytest.xfail(reason='IMPALA-122')

    vector.get_value('exec_option')['max_scan_range_length'] =\
        vector.get_value('max_scan_range_length')
    self.run_test_case('QueryTest/hdfs-tiny-scan', vector)

## Instruction:
Fix IMPALA-122: Lzo scanner with small scan ranges.
## Code After:
import pytest
from copy import copy
from tests.common.test_vector import TestDimension
from tests.common.impala_test_suite import ImpalaTestSuite, ALL_NODES_ONLY

# We use very small scan ranges to exercise corner cases in the HDFS scanner more
# thoroughly. In particular, it will exercise:
# 1. scan range with no tuple
# 2. tuple that span across multiple scan ranges
MAX_SCAN_RANGE_LENGTHS = [1, 2, 5]

class TestScanRangeLengths(ImpalaTestSuite):
  @classmethod
  def get_workload(cls):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestScanRangeLengths, cls).add_test_dimensions()
    cls.TestMatrix.add_dimension(
        TestDimension('max_scan_range_length', *MAX_SCAN_RANGE_LENGTHS))

  def test_scan_ranges(self, vector):
    if vector.get_value('table_format').file_format != 'text':
      pytest.xfail(reason='IMP-636')

    vector.get_value('exec_option')['max_scan_range_length'] =\
        vector.get_value('max_scan_range_length')
    self.run_test_case('QueryTest/hdfs-tiny-scan', vector)
