/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/ptree/column_arg.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #include "yb/yql/cql/ql/ptree/column_arg.h" |
15 | | |
16 | | #include "yb/yql/cql/ql/ptree/column_desc.h" |
17 | | #include "yb/yql/cql/ql/ptree/pt_bcall.h" |
18 | | |
19 | | namespace yb { |
20 | | namespace ql { |
21 | | |
22 | 104 | string JsonColumnOp::IndexExprToColumnName() const { |
23 | 104 | string index_column_name = desc_->MangledName(); |
24 | 118 | for (const PTExpr::SharedPtr &arg : args_->node_list()) { |
25 | 118 | index_column_name += arg->MangledName(); |
26 | 118 | } |
27 | 104 | return index_column_name; |
28 | 104 | } |
29 | | |
30 | | void FuncOp::Init(const PTExprPtr& value_expr, |
31 | | const PTExprPtr& func_expr, |
32 | 0 | yb::QLOperator yb_op) { |
33 | 0 | value_expr_ = value_expr; |
34 | 0 | func_expr_ = std::dynamic_pointer_cast<PTBcall>(func_expr); |
35 | 0 | yb_op_ = yb_op; |
36 | 0 | } |
37 | | |
38 | 198 | const char* QLOperatorAsString(QLOperator ql_op) { |
39 | 198 | switch (ql_op) { |
40 | 0 | case QL_OP_AND: |
41 | 0 | return "AND"; |
42 | 191 | case QL_OP_EQUAL: |
43 | 191 | return "="; |
44 | 0 | case QL_OP_LESS_THAN: |
45 | 0 | return "<"; |
46 | 2 | case QL_OP_LESS_THAN_EQUAL: |
47 | 2 | return "<="; |
48 | 1 | case QL_OP_GREATER_THAN: |
49 | 1 | return ">"; |
50 | 2 | case QL_OP_GREATER_THAN_EQUAL: |
51 | 2 | return ">="; |
52 | 2 | case QL_OP_IN: |
53 | 2 | return "IN"; |
54 | 0 | case QL_OP_NOT_IN: |
55 | 0 | return "NOT IN"; |
56 | 0 | case QL_OP_NOT_EQUAL: |
57 | 0 | return "!="; |
58 | 0 | default: |
59 | 0 | return ""; |
60 | 198 | } |
61 | 198 | } |
62 | | |
63 | 194 | void ColumnOp::OutputTo(std::ostream* out) const { |
64 | 194 | auto& s = *out; |
65 | 194 | s << "(" << desc()->name() << " " << QLOperatorAsString(yb_op()); |
66 | | |
67 | 194 | if (expr()->expr_op() != ExprOperator::kBindVar && expr()->ql_type_id() == DataType::STRING) { |
68 | 12 | s << " '" << expr()->QLName() << "')"; |
69 | 182 | } else { |
70 | 182 | s << " " << expr()->QLName() << ")"; |
71 | 182 | } |
72 | 194 | } |
73 | | |
74 | | } // namespace ql |
75 | | } // namespace yb |