示例#1
0
def test_table_function():

  dataset   = mock_data_set()

  schema = resolve_schema(
    dataset,
    Function('flatten', LoadOp('employees'), StringConst('roles'))
  ).schema

  eq_(schema['roles'].type,'STRING')
  eq_(schema['roles'].mode,'NULLABLE')
示例#2
0
def test_slice_op():
  dataset   = mock_data_set()
  employees = dataset.get_relation('employees')

  op = resolve_schema(
    dataset, 
    OrderByOp(LoadOp('employees'), 'manager_id')
  )
  schema = op.schema

  eq_(
    schema,
    dataset.get_schema('employees')
  )
示例#3
0
def test_slice_op():
  dataset   = mock_data_set()
  employees = dataset.get_relation('employees')

  op = resolve_schema(
    dataset, 
    SliceOp(LoadOp('employees'), 1)
  )
  schema = op.schema

  eq_(
    schema,
    dataset.get_schema('employees')
  )
示例#4
0
def test_no_operations():
  """
  Without any operations the schema should be equal to the given
  relation.
  """

  dataset   = mock_data_set()
  employees = dataset.get_relation('employees')

  schema = resolve_schema(dataset, LoadOp('employees')).schema

  assert_sequence_equal(
    schema.fields,
    employees.schema.fields
  )