コード例 #1
0
def to_ruby(self, schema):
    output = CaseOp("case", [
        WhenOp("when", self.lhs.missing(), **{"then": NotOp("not", self.rhs.missing())}),
        WhenOp("when", self.rhs.missing(), **{"then": NotOp("not", self.lhs.missing())}),
        NotOp("not", BasicEqOp("eq", [self.lhs, self.rhs]))
    ]).partial_eval().to_ruby(schema)
    return output
コード例 #2
0
ファイル: expressions.py プロジェクト: ubdussamad/mo-parquet
def to_painless(self, schema):
    return CaseOp("case", [
        WhenOp("when", self.lhs.missing(), **
               {"then": NotOp("not", self.rhs.missing())}),
        WhenOp("when", self.rhs.missing(), **
               {"then": NotOp("not", self.lhs.missing())}),
        NotOp("not", BasicEqOp("eq", [self.lhs, self.rhs]))
    ]).partial_eval().to_painless(schema)
コード例 #3
0
def partial_eval(self):
    lhs = self.lhs.partial_eval()
    rhs = self.rhs.partial_eval()

    if is_literal(lhs) and is_literal(rhs):
        return TRUE if builtin_ops["eq"](lhs.value, rhs.value) else FALSE
    else:
        rhs_missing = rhs.missing().partial_eval()
        return CaseOp([
            WhenOp(lhs.missing(), **{"then": rhs_missing}),
            WhenOp(rhs_missing, **{"then": FALSE}),
            SqlEqOp([lhs, rhs])
        ]).partial_eval()
コード例 #4
0
ファイル: expressions.py プロジェクト: nknick99/MySQL-to-S3
def partial_eval(self):
    lhs = self.lhs.partial_eval()
    rhs = self.rhs.partial_eval()

    if isinstance(lhs, Literal) and isinstance(rhs, Literal):
        return TRUE if builtin_ops["eq"](lhs.value, rhs.value) else FALSE
    else:
        rhs_missing = rhs.missing().partial_eval()
        return CaseOp("case", [
            WhenOp("when", lhs.missing(), **{"then": rhs_missing}),
            WhenOp("when", rhs_missing, **{"then": FALSE}),
            SqlEqOp("eq", [lhs, rhs])
        ]).partial_eval()
コード例 #5
0
def to_esfilter(self, schema):
    if isinstance(self.lhs, Variable) and isinstance(self.rhs, Literal):
        rhs = self.rhs.value
        lhs = self.lhs.var
        cols = schema.leaves(lhs)
        if cols:
            lhs = cols[0].es_column

        if isinstance(rhs, list):
            if len(rhs) == 1:
                return {"term": {lhs: rhs[0]}}
            else:
                return {"terms": {lhs: rhs}}
        else:
            return {"term": {lhs: rhs}}

    else:
        return CaseOp("case", [
            WhenOp("when", self.lhs.missing(), **{"then": self.rhs.missing()}),
            WhenOp("when", self.rhs.missing(), **{"then": FALSE}),
            BasicEqOp("eq", [self.lhs, self.rhs])
        ]).partial_eval().to_esfilter(schema)
コード例 #6
0
def to_ruby(self, schema):
    return CaseOp("case", [
        WhenOp("when", self.lhs.missing(), **{"then": self.rhs.missing()}),
        WhenOp("when", self.rhs.missing(), **{"then": FALSE}),
        BasicEqOp("eq", [self.lhs, self.rhs])
    ]).partial_eval().to_ruby(schema)
コード例 #7
0
def to_es14_script(self, schema, not_null=False, boolean=False, many=True):
    return CaseOp("case", [
        WhenOp("when", self.lhs.missing(), **{"then": NotOp("not", self.rhs.missing())}),
        WhenOp("when", self.rhs.missing(), **{"then": NotOp("not", self.lhs.missing())}),
        NotOp("not", BasicEqOp("eq", [self.lhs, self.rhs]))
    ]).partial_eval().to_es14_script(schema)