Пример #1
0
def test_deeply_nested_and():
    query_filter = AndFilter(fields=[
        AndFilter(fields=[
            AndFilter(fields=[_IntervalFilter('2018-04-08/2019-07-08')]),
            _IntervalFilter('2018-01-01/2020-07-08'),
        ]),
        AndFilter(fields=[
            _IntervalFilter('2017-01-01/2018-09-12'),
            OrFilter(fields=[FieldFilter('hmis_indicator_0')]),
        ]),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-04-08/2018-09-12'], tree_intervals)
Пример #2
0
def test_and_mixes_all_time():
    or_filter = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2018-02-08/2018-07-08'),
        FieldFilter('hmis_indicator_0'),
    ])
    and_filter = AndFilter(fields=[
        _IntervalFilter('2018-04-08/2019-07-08'),
        _IntervalFilter('2018-02-07/2018-06-08'),
    ])
    query_filter = AndFilter(fields=[or_filter, and_filter])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-04-08/2018-06-08'], tree_intervals)
Пример #3
0
def test_and_complex_2():
    or_filter_1 = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    or_filter_2 = OrFilter(fields=[
        _IntervalFilter('2017-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    and_filter = AndFilter(fields=[or_filter_1, or_filter_2])

    query_filter = AndFilter(
        fields=[and_filter,
                _IntervalFilter('2018-05-08/2018-09-08')])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-05-08/2018-07-08'], tree_intervals)
Пример #4
0
def test_and_disjoint():
    query_filter = AndFilter(fields=[
        _IntervalFilter('2016-02-08/2016-07-08'),
        _IntervalFilter('2017-02-08/2017-07-08'),
        _IntervalFilter('2018-02-08/2018-07-08'),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
Пример #5
0
def test_and_unsatisfiable():
    or_filter_1 = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    or_filter_2 = OrFilter(fields=[
        _IntervalFilter('2017-02-08/2017-07-08'),
        _IntervalFilter('2019-12-08/2019-12-28'),
    ])

    query_filter = AndFilter(fields=[or_filter_1, or_filter_2])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
Пример #6
0
def test_and_simple():
    query_filter = AndFilter(fields=[_IntervalFilter('2018-02-08/2018-07-08')])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-07-08'], tree_intervals)