本文整理汇总了Python中moztelemetry.dataset.Dataset.select方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.select方法的具体用法?Python Dataset.select怎么用?Python Dataset.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moztelemetry.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_dupe_properties
# 需要导入模块: from moztelemetry.dataset import Dataset [as 别名]
# 或者: from moztelemetry.dataset.Dataset import select [as 别名]
def test_select_dupe_properties():
dataset = Dataset('test-bucket', ['dim1', 'dim2']).select('field1')
with pytest.raises(Exception) as exc_info:
dataset.select('field1')
assert str(exc_info.value) == 'The property field1 has already been selected'
with pytest.raises(Exception) as exc_info:
dataset.select(field1='keyword_field')
assert str(exc_info.value) == 'The property field1 has already been selected'
示例2: test_select
# 需要导入模块: from moztelemetry.dataset import Dataset [as 别名]
# 或者: from moztelemetry.dataset.Dataset import select [as 别名]
def test_select():
dataset1 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', 'field2')
dataset2 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', field2='field2')
dataset3 = Dataset('test-bucket', ['dim1', 'dim2']).select(field1='field1', field2='field2')
assert dataset1.selection == {
'field1': 'field1',
'field2': 'field2',
}
assert dataset1.selection == dataset2.selection == dataset3.selection
dataset4 = Dataset('test-bucket', ['dim1', 'dim2']).select('field1', field2='f2', field3='f3')
assert dataset4.selection == {
'field1': 'field1',
'field2': 'f2',
'field3': 'f3',
}
dataset5 = dataset4.select('field4', field5='f5')
assert dataset5.selection == {
'field1': 'field1',
'field2': 'f2',
'field3': 'f3',
'field4': 'field4',
'field5': 'f5'
}
示例3: test_select_keep_state
# 需要导入模块: from moztelemetry.dataset import Dataset [as 别名]
# 或者: from moztelemetry.dataset.Dataset import select [as 别名]
def test_select_keep_state():
"""Test that calling select only mutates the selection of a dataset"""
dataset_before = Dataset('test-bucket', ['dim1', 'dim2']).where(dim1=True)
dataset_after = dataset_before.select('field1', 'field2')
assert dataset_before.selection != dataset_after.selection
assert dataset_before.bucket == dataset_after.bucket
assert dataset_before.schema == dataset_after.schema
assert dataset_before.store == dataset_after.store
assert dataset_before.prefix == dataset_after.prefix
assert dataset_before.clauses == dataset_after.clauses
示例4: test_records_selection
# 需要导入模块: from moztelemetry.dataset import Dataset [as 别名]
# 或者: from moztelemetry.dataset.Dataset import select [as 别名]
def test_records_selection(spark_context):
bucket_name = 'test-bucket'
store = InMemoryStore(bucket_name)
key = 'dir1/subdir1/key1'
value = '{"a": {"b": { "c": "value"}}}'
store.store[key] = value
dataset = Dataset(bucket_name, ['dim1', 'dim2'], store=store).select(field='a.b.c')
records = dataset.records(spark_context, decode=decode)
assert records.collect() == [{'field': 'value'}]
# Check that concatenating `select`s works as expected
records = dataset.select(field2='a.b').records(spark_context, decode=decode)
assert records.collect() == [{'field': 'value', 'field2': {'c': 'value'}}]