예제 #1
0
 def execute(self, environment):
     if not self.table:
         table = environment.ambiguityBetweenColumns(self.name)
         if table[0]:  # Si existe ambiguedad
             return
         else:
             if table[1]:
                 self.table = table[1]
                 col = self.table + "." + self.name
                 self.value = environment.dataFrame[col]
             else:
                 x = environment.getVar(self.name)
                 if not x:
                     list_errors.append("Error: 42703: columna  " +
                                        str(self.name) +
                                        " no existe \n En la linea: " +
                                        str(self.row))
                     self.table = ""
                     self.name = ""
                     self.value = ""
                 else:
                     self.table = x[0]
                     self.name = x[1]
                     self.value = environment.getColumn(
                         self.table, self.name)
     else:
         self.value = environment.getColumn(self.table, self.name)
     type_ = environment.getType(self.table, self.name)
     self.type = type_
     return self
예제 #2
0
 def execute(self, environment):
     exp = self.execute(environment)
     operator = self.operator
     try:
         if operator == "ISNULL":
             value = exp.value == None
         elif operator == "NOTNULL":
             value = exp.value != None
         elif operator == "ISTRUE":
             value = exp.value == True
         elif operator == "ISFALSE":
             value = exp.value == False
         elif operator == "ISUNKNOWN":
             value = exp.value == None
         elif operator == "ISNOTNULL":
             value = exp.value != None
         elif operator == "ISNOTTRUE":
             value = exp.value != True
         elif operator == "ISNOTFALSE":
             value = exp.value != False
         elif operator == "ISNOTUNKNOWN":
             value = exp.value != None
         else:
             raise TypeError
         return primitive.Primitive(TYPE.BOOLEAN, value, self.temp,
                                    self.row, self.column)
     except TypeError:
         raise list_errors.append(
             "Error: 42883: la operacion no existe entre: " + str(type) +
             " " + str(operator) + " " + "\n En la linea: " + str(self.row))
     except:
         raise list_errors.append(
             "Error: XX000: Error interno (Unary Relational Operation)" +
             "\n En la linea: " + str(self.row))
예제 #3
0
 def execute(self, environment):
     try:
         exp1 = self.exp1.execute(environment)
         exp2 = self.exp2.execute(environment)
         operator = self.operator
         if exp1.type != TYPE.STRING and exp2.type != TYPE.STRING:
             list_errors.append(
                 "Error: 42883: la operacion no existe entre: " +
                 str(exp1.type) + " " + str(operator) + " " +
                 str(exp2.type) + "\n En la linea: " + str(self.row))
             raise Exception
         if isinstance(exp1.value, pd.core.series.Series):
             exp1.value = exp1.value.apply(str)
         else:
             exp1.value = str(exp1.value)
         if isinstance(exp2.value, pd.core.series.Series):
             exp2.value = exp2.value.apply(str)
         else:
             exp2.value = str(exp2.value)
         if operator == "||":
             value = exp1.value + exp2.value
         else:
             list_errors.append("Error: 42725: el operador no es unico: " +
                                str(exp1.type) + " " + str(operator) + " " +
                                str(exp2.type) + "\n En la linea: " +
                                str(self.row))
             raise Exception
         return primitive.Primitive(TYPE.STRING, value, self.temp, self.row,
                                    self.column)
     except:
         raise list_errors.append(
             "Error: XX000: Error interno (Binary String Operation)" +
             "\n En la linea: " + str(self.row))
예제 #4
0
 def execute(self, environment):
     exp1 = self.exp1.execute(environment)
     exp2 = self.exp2.execute(environment)
     operator = self.operator
     try:
         if exp1.type != TYPE.BOOLEAN or exp2.type != TYPE.BOOLEAN:
             raise Exception
         if isinstance(exp1.value, pd.core.series.Series) or isinstance(
                 exp2.value, pd.core.series.Series):
             if operator == "AND":
                 value = exp1.value & exp2.value
             elif operator == "OR":
                 value = exp1.value | exp2.value
             else:
                 raise Exception
         else:
             if operator == "AND":
                 value = exp1.value and exp2.value
             elif operator == "OR":
                 value = exp1.value or exp2.value
             else:
                 raise Exception
         return primitive.Primitive(TYPE.BOOLEAN, value, self.temp,
                                    self.row, self.column)
     except:
         list_errors.append("Error: 42883: la operacion no existe entre: " +
                            str(exp1.type) + " " + str(operator) + " " +
                            str(exp2.type) + "\n En la linea: " +
                            str(self.row))
예제 #5
0
 def execute(self, environment):
     exp = self.execute(environment)
     operator = self.operator
     try:
         if type != TYPE.BOOLEAN:
             raise TypeError
         if isinstance(exp.value, pd.core.series.Series):
             if operator == "NOT":
                 value = ~exp.value
             elif operator == "ISTRUE":
                 value = exp.value == True
             elif operator == "ISFALSE":
                 value = exp.value == False
             elif operator == "ISUNKNOWN":
                 value = exp.value == None
             elif operator == "ISNOTTRUE":
                 value = exp.value != True
             elif operator == "ISNOTFALSE":
                 value = exp.value != False
             elif operator == "ISNOTUNKNOWN":
                 value = exp.value != None
             else:
                 raise TypeError
         else:
             if operator == "NOT":
                 value = not exp.value
             elif operator == "ISTRUE":
                 value = exp.value == True
             elif operator == "ISFALSE":
                 value = exp.value == False
             elif operator == "ISUNKNOWN":
                 value = exp.value == None
             elif operator == "ISNOTTRUE":
                 value = exp.value != True
             elif operator == "ISNOTFALSE":
                 value = exp.value != False
             elif operator == "ISNOTUNKNOWN":
                 value = exp.value != None
             else:
                 raise TypeError
         return primitive.Primitive(TYPE.BOOLEAN, value, self.temp,
                                    self.row, self.column)
     except TypeError:
         raise list_errors.append(
             "Error: 42883: la operacion no existe entre: " + str(type) +
             " y el operador " + str(operator) + "\n En la linea: " +
             str(self.row))
     except:
         raise list_errors.append(
             "Error: XX000: Error interno (Binary Aritmethic Operation)" +
             "\n En la linea: " + str(self.row))
예제 #6
0
 def execute(self, environment):
     exp = self.execute(environment)
     operator = self.operator
     if type != TYPE.NUMBER:
         list_errors.append("Error: 42883: la operacion no existe entre: " +
                            str(operator) + " " + str(type) +
                            "\n En la linea: " + str(self.row))
         return ArithmeticError
     if operator == "+":
         value = exp.value
     elif operator == "-":
         value = exp.value * -1
     else:
         list_errors.append("Error: 42883: la operacion no existe entre: " +
                            str(operator) + " " + str(type) +
                            "\n En la linea: " + str(self.row))
         raise Exception
     return primitive.Primitive(TYPE.NUMBER, value, self.temp, self.row,
                                self.column)
예제 #7
0
 def execute(self, environment):
     exp1 = self.exp1.execute(environment)
     exp2 = self.exp2.execute(environment)
     operator = self.operator
     try:
         if operator == "<":
             value = exp1.value < exp2.value
         elif operator == ">":
             value = exp1.value > exp2.value
         elif operator == ">=":
             value = exp1.value >= exp2.value
         elif operator == "<=":
             value = exp1.value <= exp2.value
         elif operator == "=":
             value = exp1.value == exp2.value
         elif operator == "!=":
             value = exp1.value != exp2.value
         elif operator == "<>":
             value = exp1.value != exp2.value
         elif operator == "ISDISTINCTFROM":
             value = exp1.value != exp2.value
         elif operator == "ISNOTDISTINCTFROM":
             value = exp1.value == exp2.value
         else:
             list_errors.append("Error: 22P02: entrada invalida: " +
                                str(exp1.type) + " " + str(operator) + " " +
                                str(exp2.type) + "\n En la linea: " +
                                str(self.row))
             raise Exception
         return primitive.Primitive(TYPE.BOOLEAN, value, self.temp,
                                    self.row, self.column)
     except TypeError:
         list_errors.append("Error: 42883: la operacion no existe entre: " +
                            str(exp1.type) + " " + str(operator) + " " +
                            str(exp2.type) + "\n En la linea: " +
                            str(self.row))
         raise Exception
     except:
         raise list_errors.append(
             "Error: XX000: Error interno (Binary Relational Operation)" +
             "\n En la linea: " + str(self.row))
예제 #8
0
 def execute(self, environment):
     exp1 = self.exp1.execute(environment)
     exp2 = self.exp2.execute(environment)
     exp3 = self.exp3.execute(environment)
     operator = self.operator
     try:
         if (isinstance(exp1.value, pd.core.series.Series)
                 or isinstance(exp2.value, pd.core.series.Series)
                 or isinstance(exp3.value, pd.core.series.Series)):
             if operator == "BETWEEN":
                 value = (exp1.value > exp2.value) & (exp1.value <
                                                      exp3.value)
             elif operator == "NOTBETWEEN":
                 value = not ((exp1.value > exp2.value) &
                              (exp1.value < exp3.value))
             elif operator == "BETWEENSYMMETRIC":
                 t1 = (exp1.value > exp2.value) & (exp1.value < exp3.value)
                 t2 = (exp1.value < exp2.value) & (exp1.value > exp3.value)
                 value = t1 | t2
             else:
                 list_errors.append("Error: 42601: Error sintactico: " +
                                    "\n En la linea: " + str(self.row))
                 return AssertionError
         else:
             if operator == "BETWEEN":
                 value = exp1.value > exp2.value and exp1.value < exp3.value
             elif operator == "NOTBETWEEN":
                 value = not (exp1.value > exp2.value
                              and exp1.value < exp3.value)
             elif operator == "BETWEENSYMMETRIC":
                 t1 = exp1.value > exp2.value and exp1.value < exp3.value
                 t2 = exp1.value < exp2.value and exp1.value > exp3.value
                 value = t1 or t2
             else:
                 list_errors.append("Error: 42601: Error sintactico: " +
                                    "\n En la linea: " + str(self.row))
                 return AssertionError
         return primitive.Primitive(TYPE.BOOLEAN, value, self.temp,
                                    self.row, self.column)
     except TypeError:
         list_errors.append("Error: 42883: la operacion no existe entre: " +
                            str(exp1.type) + " " + str(operator) + " " +
                            str(exp2.type) + " y " + str(exp3.type) +
                            "\n En la linea: " + str(self.row))
         return AssertionError
     except:
         list_errors.append(
             "Error: XX000: Error interno (Ternary Relational Operation)" +
             "\n En la linea: " + str(self.row))
         pass
예제 #9
0
 def execute(self, environment):
     exp1 = self.exp1.execute(environment)
     exp2 = self.exp2.execute(environment)
     operator = self.operator
     try:
         if exp1.type != TYPE.NUMBER or exp2.type != TYPE.NUMBER:
             raise TypeError
         if operator == "+":
             value = exp1.value + exp2.value
         elif operator == "-":
             value = exp1.value - exp2.value
         elif operator == "*":
             value = exp1.value * exp2.value
         elif operator == "/":
             if exp2.value == 0:
                 list_errors.append(
                     "Error: 22012: No se puede dividir  por cero")
                 value = 0
             else:
                 value = exp1.value / exp2.value
         elif operator == "^":
             value = exp1.value**exp2.value
         elif operator == "%":
             if exp2.value == 0:
                 list_errors.append(
                     "Error: 22012: No se puede modular por cero")
                 value = 0
             else:
                 value = exp1.value % exp2.value
         else:
             raise TypeError
         return primitive.Primitive(TYPE.NUMBER, value, self.temp, self.row,
                                    self.column)
     except TypeError:
         raise list_errors.append(
             "Error: 42883: la operacion no existe entre: " +
             str(exp1.type) + " " + str(operator) + " " + str(exp2.type) +
             "\n En la linea: " + str(self.row))
     except:
         raise list_errors.append(
             "Error: XX000: Error interno (Binary Aritmethic Operation)" +
             "\n En la linea: " + str(self.row))