Esempio n. 1
0
def test_using_model():
    assert parse_bql_string('simulate x from t using model 42'
            ' limit 10') == \
        [ast.Simulate(['x'], 't', ast.ExpLit(ast.LitInt(42)), [],
            ast.ExpLit(ast.LitInt(10)))]
    with pytest.raises(parse.BQLParseError):
        assert parse_bql_string('simulate x from t'
                ' using model (87)') == \
            [ast.Simulate(['x'], 't', ast.ExpLit(ast.LitInt(87)), [],
                ast.ExpLit(ast.LitInt(10)))]
    assert parse_bql_string('estimate x from t using model (1+2)') == \
        [ast.Estimate(ast.SELQUANT_ALL,
            [ast.SelColExp(ast.ExpCol(None, 'x'), None)],
            't',
            ast.ExpOp(ast.OP_ADD, (
                ast.ExpLit(ast.LitInt(1)),
                ast.ExpLit(ast.LitInt(2)),
            )),
            None, None, None, None)]
    assert parse_bql_string('estimate * from columns of t'
            ' using model modelno') == \
        [ast.EstCols([ast.SelColAll(None)], 't', ast.ExpCol(None, 'modelno'),
            None, None, None)]
    assert parse_bql_string('estimate 42 from columns of t'
            ' using model modelno') == \
        [ast.EstCols([(ast.ExpLit(ast.LitInt(42)), None)], 't',
            ast.ExpCol(None, 'modelno'),
            None, None, None)]
    assert parse_bql_string('estimate 42 from pairwise columns of t'
            ' using model modelno') == \
        [ast.EstPairCols([(ast.ExpLit(ast.LitInt(42)), None)], 't', None,
            ast.ExpCol(None, 'modelno'),
            None, None, None)]
    assert parse_bql_string('estimate similarity from pairwise t'
            ' using model modelno') == \
        [ast.EstPairRow([ast.SelColExp(ast.ExpBQLSim(None, [ast.ColListAll()]),
                None)],
            't', ast.ExpCol(None, 'modelno'),
            None, None, None)]
    assert parse_bql_string('infer x from t using model modelno') == \
        [ast.InferAuto([ast.InfColOne('x', None)], ast.ExpLit(ast.LitInt(0)),
            't', ast.ExpCol(None, 'modelno'),
            None, None, None, None)]
    assert parse_bql_string('infer explicit x from t using model modelno') == \
        [ast.InferExplicit([ast.SelColExp(ast.ExpCol(None, 'x'), None)],
            't', ast.ExpCol(None, 'modelno'),
            None, None, None, None)]
Esempio n. 2
0
def test_infer_conf_samples():
    assert parse_bql_string('infer x with confidence 0.9 using 42 samples'
            ' from p') == \
        [ast.InferAuto([ast.InfColOne('x', None)],
            ast.ExpLit(ast.LitInt(.9)), ast.ExpLit(ast.LitInt(42)), 'p', None,
            None, None, None, None)]
Esempio n. 3
0
def test_infer_samples():
    assert parse_bql_string('infer x using 42 samples from p') == \
        [ast.InferAuto([ast.InfColOne('x', None)],
            ast.ExpLit(ast.LitInt(0)), ast.ExpLit(ast.LitInt(42)), 'p', None,
            None, None, None, None)]
Esempio n. 4
0
def test_infer_conf():
    assert parse_bql_string('infer x with confidence 0.9 from p') == \
        [ast.InferAuto([ast.InfColOne('x', None)],
            ast.ExpLit(ast.LitFloat(0.9)), None, 'p', None, None, None, None,
            None)]
Esempio n. 5
0
def test_infer_trivial():
    assert parse_bql_string('infer x from p') == \
        [ast.InferAuto([ast.InfColOne('x', None)], ast.ExpLit(ast.LitInt(0)),
            None, 'p', None, None, None, None, None)]
Esempio n. 6
0
 def p_infer_auto_column_one(self, col, name):
     return ast.InfColOne(col, name)