|
| 1 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +syntax = "proto3"; |
| 6 | + |
| 7 | +import "proto/analyzed-conjunction.proto"; |
| 8 | +import "proto/concept.proto"; |
| 9 | +import "proto/error.proto"; |
| 10 | +import "proto/options.proto"; |
| 11 | + |
| 12 | +package typedb.protocol; |
| 13 | + |
| 14 | +message Analyze { |
| 15 | + |
| 16 | + message Req { |
| 17 | + Options.Analyze options = 1; |
| 18 | + string query = 2; |
| 19 | + } |
| 20 | + |
| 21 | + message Res { |
| 22 | + oneof result { |
| 23 | + Error err = 1; |
| 24 | + AnalyzedQuery ok = 2; |
| 25 | + } |
| 26 | + |
| 27 | + message AnalyzedQuery { |
| 28 | + string source = 1; |
| 29 | + Pipeline query = 2; |
| 30 | + repeated Function preamble = 3; |
| 31 | + Fetch fetch = 4; |
| 32 | + |
| 33 | + message Function { |
| 34 | + Pipeline body = 1; |
| 35 | + repeated AnalyzedConjunction.Variable arguments = 2; |
| 36 | + repeated AnalyzedConjunction.VariableAnnotations arguments_annotations = 3; |
| 37 | + repeated AnalyzedConjunction.VariableAnnotations return_annotations = 4; |
| 38 | + ReturnOperation return_operation = 5; |
| 39 | + |
| 40 | + message ReturnOperation { |
| 41 | + oneof return_operation { |
| 42 | + ReturnOpStream stream = 1; |
| 43 | + ReturnOpSingle single = 2; |
| 44 | + ReturnOpCheck check = 3; |
| 45 | + ReturnOpReduce reduce = 4; |
| 46 | + }; |
| 47 | + message ReturnOpStream { |
| 48 | + repeated AnalyzedConjunction.Variable variables = 1; |
| 49 | + } |
| 50 | + message ReturnOpSingle { |
| 51 | + string selector = 1; |
| 52 | + repeated AnalyzedConjunction.Variable variables = 2; |
| 53 | + } |
| 54 | + message ReturnOpCheck {} |
| 55 | + message ReturnOpReduce { |
| 56 | + repeated Reducer reducers = 1; |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + message Pipeline { |
| 62 | + repeated AnalyzedConjunction conjunctions = 1; |
| 63 | + repeated PipelineStage stages = 2; |
| 64 | + map<uint32, VariableInfo> variable_info = 3; |
| 65 | + repeated AnalyzedConjunction.Variable outputs = 4; |
| 66 | + |
| 67 | + message VariableInfo { |
| 68 | + string name = 1; |
| 69 | + } |
| 70 | + |
| 71 | + message PipelineStage { |
| 72 | + oneof stage { |
| 73 | + Match match = 1; |
| 74 | + Insert insert = 2; |
| 75 | + Put put = 3; |
| 76 | + Update update = 4; |
| 77 | + Delete delete = 5; |
| 78 | + Select select = 6; |
| 79 | + Sort sort = 7; |
| 80 | + Require require = 8; |
| 81 | + Offset offset = 9; |
| 82 | + Limit limit = 10; |
| 83 | + Distinct distinct = 11; |
| 84 | + Reduce reduce = 12; |
| 85 | + } |
| 86 | + |
| 87 | + message Match { |
| 88 | + uint32 block = 1; |
| 89 | + } |
| 90 | + message Insert { |
| 91 | + uint32 block = 1; |
| 92 | + } |
| 93 | + message Put { |
| 94 | + uint32 block = 1; |
| 95 | + } |
| 96 | + message Update { |
| 97 | + uint32 block = 1; |
| 98 | + } |
| 99 | + message Delete { |
| 100 | + uint32 block = 1; |
| 101 | + repeated AnalyzedConjunction.Variable deleted_variables = 2; |
| 102 | + } |
| 103 | + |
| 104 | + message Select { |
| 105 | + repeated AnalyzedConjunction.Variable variables = 1; |
| 106 | + } |
| 107 | + message Sort { |
| 108 | + repeated SortVariable sort_variables = 1; |
| 109 | + message SortVariable { |
| 110 | + AnalyzedConjunction.Variable variable = 1; |
| 111 | + SortDirection direction = 2; |
| 112 | + enum SortDirection { |
| 113 | + ASC = 0; |
| 114 | + DESC = 1; |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + message Require { |
| 119 | + repeated AnalyzedConjunction.Variable variables = 1; |
| 120 | + } |
| 121 | + message Offset { |
| 122 | + uint64 offset = 1; |
| 123 | + } |
| 124 | + message Limit { |
| 125 | + uint64 limit = 1; |
| 126 | + } |
| 127 | + message Distinct {} |
| 128 | + message Reduce { |
| 129 | + repeated ReduceAssign reducers = 1; |
| 130 | + repeated AnalyzedConjunction.Variable groupby = 2; |
| 131 | + |
| 132 | + message ReduceAssign { |
| 133 | + AnalyzedConjunction.Variable assigned = 1; |
| 134 | + Reducer reducer = 2; |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + message Reducer { |
| 141 | + string reducer = 1; |
| 142 | + repeated AnalyzedConjunction.Variable variables = 2; |
| 143 | + } |
| 144 | + |
| 145 | + message Fetch { |
| 146 | + oneof node { |
| 147 | + Object object = 1; |
| 148 | + Fetch list = 2; |
| 149 | + Leaf leaf = 3; |
| 150 | + } |
| 151 | + message Object { |
| 152 | + map<string, Fetch> fetch = 1; |
| 153 | + } |
| 154 | + message Leaf { |
| 155 | + repeated ValueType annotations = 1; |
| 156 | + } |
| 157 | + } |
| 158 | + } |
| 159 | + } |
| 160 | +} |
0 commit comments