Пример #1
0
def column(function=None, temporary=False, cache=False):
    from remake.schematic.cache import SchematicCache

    if function is None:
        return partial(column, temporary=temporary, cache=cache)

    transformer, column_name, input_columns = get_info(function)
    function = function if not cache else lru_cache(function)

    spec = ColumnOperator(name=column_name,
                          input_columns=input_columns,
                          is_view=temporary,
                          transform=function)

    SchematicCache.add_column(transformer, spec)

    return function
Пример #2
0
def test_core_generation():
    name = "TEST"
    SchematicCache.add_column(name, ColumnSpec("test", [], False, lambda: True, False))
    SchematicCache.add_condition(name, ConditionSpec("test", [], lambda: True, ""))
    SchematicCache.add_copy(name, CopySpec("test", "test"))
    SchematicCache.add_group(name, GroupSpec(name="test", sources=[], transform=None, sort_by=None))
    SchematicCache.add_index(name, IndexSpec("test", []))
    SchematicCache.add_parameter(name, ParameterSpec("Test", "Test", None, None, None, None, None))
    SchematicCache.add_sorts(name, SortBySpec([]))
    SchematicCache.add_explode(name, ExplodeSpec([], None))
    SchematicCache.add_expand(name, ExpandSpec([], None))
    SchematicCache.add_join(name, JoinSpec([], None))

    core = SchematicCache.get(name)
    assert len(core.columns) == 1
    assert len(core.copies) == 1
    assert len(core.groups) == 1
    assert len(core.indexes) == 1
    assert len(core.parameters) == 1
    assert len(core.sorts) == 1
    assert len(core.explodes) == 1
    assert len(core.expands) == 1
    assert len(core.joins) == 1