|
| 1 | +package sqlancer.databend.ast; |
| 2 | + |
| 3 | +import sqlancer.Randomly; |
| 4 | +import sqlancer.common.ast.BinaryOperatorNode; |
| 5 | +import sqlancer.common.ast.newast.NewUnaryPostfixOperatorNode; |
| 6 | +import sqlancer.common.ast.newast.Node; |
| 7 | +import sqlancer.databend.DatabendSchema.DatabendDataType; |
| 8 | + |
| 9 | + |
| 10 | +public class DatabendUnaryPostfixOperation extends NewUnaryPostfixOperatorNode<DatabendExpression> { |
| 11 | + |
| 12 | +// private final Node<DatabendExpression> expr; |
| 13 | +// private final DatabendUnaryPostfixOperator op; |
| 14 | + private boolean negate; |
| 15 | + |
| 16 | + public DatabendUnaryPostfixOperation(Node<DatabendExpression> expr, DatabendUnaryPostfixOperator op, boolean negate) { |
| 17 | + super(expr,op); |
| 18 | + setNegate(negate); |
| 19 | + } |
| 20 | + |
| 21 | + public enum DatabendUnaryPostfixOperator implements BinaryOperatorNode.Operator { |
| 22 | + IS_NULL("IS NULL"){ |
| 23 | + @Override |
| 24 | + public DatabendDataType[] getInputDataTypes() { |
| 25 | + return DatabendDataType.values(); |
| 26 | + } |
| 27 | + }, |
| 28 | + IS_NOT_NULL("IS NOT NULL"){ |
| 29 | + @Override |
| 30 | + public DatabendDataType[] getInputDataTypes() { |
| 31 | + return DatabendDataType.values(); |
| 32 | + } |
| 33 | + }; |
| 34 | + //IS |
| 35 | + |
| 36 | + private final String textRepresentations; |
| 37 | + |
| 38 | + DatabendUnaryPostfixOperator(String text) { |
| 39 | + this.textRepresentations = text; |
| 40 | + } |
| 41 | + |
| 42 | + public static DatabendUnaryPostfixOperator getRandom() { |
| 43 | + return Randomly.fromOptions(values()); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public String getTextRepresentation() { |
| 48 | + return textRepresentations; |
| 49 | + } |
| 50 | + |
| 51 | + public abstract DatabendDataType[] getInputDataTypes(); |
| 52 | + |
| 53 | + } |
| 54 | + |
| 55 | + public boolean isNegated() { |
| 56 | + return negate; |
| 57 | + } |
| 58 | + |
| 59 | + public void setNegate(boolean negate) { |
| 60 | + this.negate = negate; |
| 61 | + } |
| 62 | + |
| 63 | +// @Override |
| 64 | + public Node<DatabendExpression> getExpression() { |
| 65 | + return getExpr(); |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public String getOperatorRepresentation() { |
| 70 | + return this.op.getTextRepresentation(); |
| 71 | + } |
| 72 | + |
| 73 | +// @Override |
| 74 | +// public OperatorKind getOperatorKind() { |
| 75 | +// return OperatorKind.POSTFIX; |
| 76 | +// } |
| 77 | +} |
0 commit comments