コード例 #1
0
def to_ruby(self, schema):
    if not self.terms:
        return TRUE.to_ruby()
    else:
        return Ruby(miss=FALSE,
                    type=BOOLEAN,
                    expr=" && ".join("(" + t.to_ruby(schema).expr + ")"
                                     for t in self.terms),
                    frum=self)
コード例 #2
0
def to_ruby(self, schema):
    value = self.term.to_ruby(schema)
    if value.expr or value.i:
        return TRUE.to_ruby(schema)
    else:
        return Ruby(miss=FALSE,
                    type=BOOLEAN,
                    expr="(" + value.expr + ") instanceof java.lang.Double",
                    frum=self)
コード例 #3
0
ファイル: expressions.py プロジェクト: rv404674/TUID
def to_es_script(self, schema):
    if not self.terms:
        return TRUE.to_es_script()
    else:
        return EsScript(
            miss=FALSE,
            type=BOOLEAN,
            expr=" && ".join("(" + t.to_es_script(schema).expr + ")" for t in self.terms),
            frum=self
        )
コード例 #4
0
def to_es14_script(self, schema, not_null=False, boolean=False, many=True):
    if not self.terms:
        return TRUE.to_es14_script()
    else:
        return EsScript(
            miss=FALSE,
            type=BOOLEAN,
            expr=" && ".join("(" + t.to_es14_script(schema).expr + ")" for t in self.terms),
            frum=self
        )
コード例 #5
0
 def to_es_script(self, schema, not_null=False, boolean=False, many=True):
     if not self.terms:
         return TRUE.to_es_script()
     else:
         return EsScript(
             type=BOOLEAN,
             expr=" && ".join("(" + Painless[t].to_es_script(schema).expr +
                              ")" for t in self.terms),
             frum=self,
             schema=schema,
         )
コード例 #6
0
ファイル: expressions.py プロジェクト: rv404674/TUID
def to_es_script(self, schema):
    value = self.term.to_es_script(schema)
    if value.expr or value.i:
        return TRUE.to_es_script(schema)
    else:
        return EsScript(
            miss=FALSE,
            type=BOOLEAN,
            expr="(" + value.expr + ") instanceof java.lang.Double",
            frum=self
        )
コード例 #7
0
def to_es14_script(self, schema, not_null=False, boolean=False, many=True):
    value = self.term.to_es14_script(schema)
    if value.expr or value.i:
        return TRUE.to_es14_script(schema)
    else:
        return EsScript(
            miss=FALSE,
            type=BOOLEAN,
            expr="(" + value.expr + ") instanceof java.lang.Double",
            frum=self
        )
コード例 #8
0
ファイル: and_op.py プロジェクト: klahnakoski/pyLibrary
    def to_bq(self, schema, not_null=False, boolean=False):
        if not self.terms:
            return TRUE.to_bq(schema)

        return BQLScript(
            expr=JoinSQL(SQL_AND, [self.lang[t].to_bq(schema) for t in self.terms if t != None]),
            data_type=BOOLEAN,
            frum=self,
            miss=FALSE,
            schema=schema,
        )
コード例 #9
0
 def to_bq(self, schema, not_null=False, boolean=False):
     term = BQLang[self.term].partial_eval()
     if term.type == "boolean":
         sql = term.to_bq(schema)
         return sql
     elif is_literal(term) and term.value in ("T", "F"):
         if term.value == "T":
             return TRUE.to_bq(schema)
         else:
             return FALSE.to_bq(schema)
     else:
         sql = term.exists().partial_eval().to_bq(schema)
         return sql
コード例 #10
0
ファイル: painless.py プロジェクト: klahnakoski/pyLibrary
 def to_es_script(self, schema, not_null=False, boolean=False, many=True):
     if not self.terms:
         return TRUE.to_es_script()
     else:
         return EsScript(
             type=BOOLEAN,
             expr=" && ".join(
                 "(" + Painless[t].to_es_script(schema).expr + ")"
                 for t in self.terms
             ),
             frum=self,
             schema=schema,
         )
コード例 #11
0
    def to_es_script(self, schema, not_null=False, boolean=False, many=True):
        simple_rhs = Painless[self.rhs].partial_eval()
        lhs = Painless[self.lhs].partial_eval().to_es_script(schema)
        rhs = simple_rhs.to_es_script(schema)

        if lhs.many:
            if rhs.many:
                return AndOp([
                    EsScript(
                        type=BOOLEAN,
                        expr="(" + lhs.expr + ").size()==(" + rhs.expr +
                        ").size()",
                        frum=self,
                        schema=schema,
                    ),
                    EsScript(
                        type=BOOLEAN,
                        expr="(" + rhs.expr + ").containsAll(" + lhs.expr +
                        ")",
                        frum=self,
                        schema=schema,
                    ),
                ]).to_es_script(schema)
            else:
                if lhs.type == BOOLEAN:
                    if is_literal(simple_rhs) and simple_rhs.value in ("F",
                                                                       False):
                        return EsScript(type=BOOLEAN,
                                        expr="!" + lhs.expr,
                                        frum=self,
                                        schema=schema)
                    elif is_literal(simple_rhs) and simple_rhs.value in ("T",
                                                                         True):
                        return EsScript(type=BOOLEAN,
                                        expr=lhs.expr,
                                        frum=self,
                                        schema=schema)
                    else:
                        return EsScript(
                            type=BOOLEAN,
                            expr="(" + lhs.expr + ")==(" + rhs.expr + ")",
                            frum=self,
                            schema=schema,
                        )
                elif lhs.type == rhs.type:
                    return EsScript(
                        type=BOOLEAN,
                        expr="(" + lhs.expr + ").contains(" + rhs.expr + ")",
                        frum=self,
                        schema=schema,
                    )
                elif lhs.type == NUMBER and rhs.type == INTEGER:
                    return EsScript(
                        type=BOOLEAN,
                        expr="(" + lhs.expr + ").contains((double)" +
                        rhs.expr + ")",
                        frum=self,
                        schema=schema,
                    )
                else:
                    Log.error(
                        "type mismatch not expected while converting to painless"
                    )

        elif rhs.many:
            return EsScript(
                type=BOOLEAN,
                expr="(" + rhs.expr + ").contains(" + lhs.expr + ")",
                frum=self,
                schema=schema,
            )
        else:
            if lhs is null_script:
                if rhs is null_script:
                    return TRUE.to_es_script(schema)
                return FALSE.to_es_script(schema)
            elif lhs.type == BOOLEAN:
                if is_literal(simple_rhs) and simple_rhs.value in ("F", False):
                    return EsScript(type=BOOLEAN,
                                    expr="!" + lhs.expr,
                                    frum=self,
                                    schema=schema)
                elif is_literal(simple_rhs) and simple_rhs.value in ("T",
                                                                     True):
                    return EsScript(type=BOOLEAN,
                                    expr=lhs.expr,
                                    frum=self,
                                    schema=schema)
                else:
                    return EsScript(
                        type=BOOLEAN,
                        expr="(" + lhs.expr + ")==(" + rhs.expr + ")",
                        frum=self,
                        schema=schema,
                    )
            else:
                return EsScript(
                    type=BOOLEAN,
                    expr="(" + lhs.expr + ")==(" + rhs.expr + ")",
                    frum=self,
                    schema=schema,
                )