@finos/legend-query-builder 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +42 -9
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderComponentTestUtils.js +2 -5
  6. package/lib/components/QueryBuilderComponentTestUtils.js.map +1 -1
  7. package/lib/components/QueryBuilderDiffPanel.js +2 -2
  8. package/lib/components/QueryBuilderDiffPanel.js.map +1 -1
  9. package/lib/components/QueryBuilderResultPanel.js +3 -3
  10. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderSideBar.js +2 -1
  12. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  13. package/lib/components/QueryBuilder_TestID.d.ts +1 -0
  14. package/lib/components/QueryBuilder_TestID.d.ts.map +1 -1
  15. package/lib/components/QueryBuilder_TestID.js +1 -0
  16. package/lib/components/QueryBuilder_TestID.js.map +1 -1
  17. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  18. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +2 -2
  19. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  20. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.d.ts +23 -0
  21. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.d.ts.map +1 -0
  22. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.js +363 -0
  23. package/lib/components/fetch-structure/QueryBuilderOlapGroupByPanel.js.map +1 -0
  24. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  25. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +21 -53
  26. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  27. package/lib/components/fetch-structure/QueryBuilderPostTDSPanel.d.ts +23 -0
  28. package/lib/components/fetch-structure/QueryBuilderPostTDSPanel.d.ts.map +1 -0
  29. package/lib/components/fetch-structure/QueryBuilderPostTDSPanel.js +32 -0
  30. package/lib/components/fetch-structure/QueryBuilderPostTDSPanel.js.map +1 -0
  31. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  32. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +2 -1
  33. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  34. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts +27 -0
  35. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.d.ts.map +1 -0
  36. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.js +61 -0
  37. package/lib/components/fetch-structure/QueryBuilderTDSComponentHelper.js.map +1 -0
  38. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  39. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +4 -13
  40. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  41. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  42. package/lib/components/shared/LambdaEditor.js +23 -7
  43. package/lib/components/shared/LambdaEditor.js.map +1 -1
  44. package/lib/components/workflows/ServiceQueryBuilder.d.ts.map +1 -1
  45. package/lib/components/workflows/ServiceQueryBuilder.js +5 -1
  46. package/lib/components/workflows/ServiceQueryBuilder.js.map +1 -1
  47. package/lib/graphManager/QueryBuilderHashUtils.d.ts +14 -0
  48. package/lib/graphManager/QueryBuilderHashUtils.d.ts.map +1 -1
  49. package/lib/graphManager/QueryBuilderHashUtils.js +15 -0
  50. package/lib/graphManager/QueryBuilderHashUtils.js.map +1 -1
  51. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts +7 -1
  52. package/lib/graphManager/QueryBuilderSupportedFunctions.d.ts.map +1 -1
  53. package/lib/graphManager/QueryBuilderSupportedFunctions.js +7 -0
  54. package/lib/graphManager/QueryBuilderSupportedFunctions.js.map +1 -1
  55. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
  56. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +4 -1
  57. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  58. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +1 -0
  59. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
  60. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +50 -0
  61. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
  62. package/lib/index.css +2 -2
  63. package/lib/index.css.map +1 -1
  64. package/lib/package.json +6 -6
  65. package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
  66. package/lib/stores/QueryBuilderStateBuilder.js +7 -1
  67. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  68. package/lib/stores/QueryBuilderStateTestUtils.d.ts.map +1 -1
  69. package/lib/stores/QueryBuilderStateTestUtils.js +2 -4
  70. package/lib/stores/QueryBuilderStateTestUtils.js.map +1 -1
  71. package/lib/stores/QueryBuilderTypeaheadHelper.js +2 -2
  72. package/lib/stores/explorer/QueryBuilderExplorerState.js +3 -3
  73. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
  74. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
  75. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js +3 -0
  76. package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
  77. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
  78. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +2 -1
  79. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  80. package/lib/stores/fetch-structure/tds/QueryBuilderTDSColumnState_.d.ts +24 -0
  81. package/lib/stores/fetch-structure/tds/QueryBuilderTDSColumnState_.d.ts.map +1 -0
  82. package/lib/stores/fetch-structure/tds/QueryBuilderTDSColumnState_.js +20 -0
  83. package/lib/stores/fetch-structure/tds/QueryBuilderTDSColumnState_.js.map +1 -0
  84. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts +23 -0
  85. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.d.ts.map +1 -0
  86. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js +41 -0
  87. package/lib/stores/fetch-structure/tds/QueryBuilderTDSHelper.js.map +1 -0
  88. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +11 -0
  89. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
  90. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +44 -1
  91. package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
  92. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts +2 -2
  93. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts.map +1 -1
  94. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js +2 -2
  95. package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js.map +1 -1
  96. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.js +1 -1
  97. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts +4 -4
  98. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.d.ts.map +1 -1
  99. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js +8 -7
  100. package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js.map +1 -1
  101. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByOperatorLoader.d.ts +18 -0
  102. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByOperatorLoader.d.ts.map +1 -0
  103. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByOperatorLoader.js +36 -0
  104. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByOperatorLoader.js.map +1 -0
  105. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByState.d.ts +91 -0
  106. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByState.d.ts.map +1 -0
  107. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByState.js +272 -0
  108. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByState.js.map +1 -0
  109. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.d.ts +19 -0
  110. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.d.ts.map +1 -0
  111. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.js +100 -0
  112. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.js.map +1 -0
  113. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByValueSpecificationBuilder.d.ts +19 -0
  114. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByValueSpecificationBuilder.d.ts.map +1 -0
  115. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByValueSpecificationBuilder.js +83 -0
  116. package/lib/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByValueSpecificationBuilder.js.map +1 -0
  117. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_.d.ts +29 -0
  118. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_.d.ts.map +1 -0
  119. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_.js +30 -0
  120. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_.js.map +1 -0
  121. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Average.d.ts +25 -0
  122. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Average.d.ts.map +1 -0
  123. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Average.js +50 -0
  124. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Average.js.map +1 -0
  125. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Count.d.ts +25 -0
  126. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Count.d.ts.map +1 -0
  127. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Count.js +51 -0
  128. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Count.js.map +1 -0
  129. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Max.d.ts +25 -0
  130. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Max.d.ts.map +1 -0
  131. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Max.js +50 -0
  132. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Max.js.map +1 -0
  133. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Min.d.ts +25 -0
  134. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Min.d.ts.map +1 -0
  135. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Min.js +50 -0
  136. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Min.js.map +1 -0
  137. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Sum.d.ts +25 -0
  138. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Sum.d.ts.map +1 -0
  139. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Sum.js +51 -0
  140. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Sum.js.map +1 -0
  141. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_AverageRank_.d.ts +24 -0
  142. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_AverageRank_.d.ts.map +1 -0
  143. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_AverageRank_.js +48 -0
  144. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_AverageRank_.js.map +1 -0
  145. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_DenseRank_.d.ts +24 -0
  146. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_DenseRank_.d.ts.map +1 -0
  147. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_DenseRank_.js +48 -0
  148. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_DenseRank_.js.map +1 -0
  149. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_Rank_.d.ts +24 -0
  150. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_Rank_.d.ts.map +1 -0
  151. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_Rank_.js +48 -0
  152. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_Rank_.js.map +1 -0
  153. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_RowNumber_.d.ts +24 -0
  154. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_RowNumber_.d.ts.map +1 -0
  155. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_RowNumber_.js +48 -0
  156. package/lib/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_RowNumber_.js.map +1 -0
  157. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.d.ts +1 -1
  158. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js +2 -2
  159. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +6 -4
  160. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
  161. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +14 -3
  162. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
  163. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
  164. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +8 -11
  165. package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  166. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.d.ts +2 -2
  167. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.d.ts.map +1 -1
  168. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.js +5 -1
  169. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.js.map +1 -1
  170. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +4 -4
  171. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +1 -1
  172. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +1 -1
  173. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +3 -3
  174. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +3 -3
  175. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +1 -1
  176. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +2 -2
  177. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts +2 -2
  178. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +3 -3
  179. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +3 -3
  180. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js +1 -1
  181. package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +1 -1
  182. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts +4 -6
  183. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
  184. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js +6 -5
  185. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js.map +1 -1
  186. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
  187. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +1 -0
  188. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  189. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  190. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +6 -3
  191. package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  192. package/lib/stores/filter/QueryBuilderFilterState.d.ts +2 -0
  193. package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
  194. package/lib/stores/filter/QueryBuilderFilterState.js +6 -0
  195. package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
  196. package/package.json +13 -13
  197. package/src/components/QueryBuilder.tsx +110 -35
  198. package/src/components/QueryBuilderComponentTestUtils.tsx +9 -11
  199. package/src/components/QueryBuilderDiffPanel.tsx +2 -2
  200. package/src/components/QueryBuilderResultPanel.tsx +4 -4
  201. package/src/components/QueryBuilderSideBar.tsx +4 -1
  202. package/src/components/QueryBuilder_TestID.ts +1 -0
  203. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +2 -3
  204. package/src/components/fetch-structure/QueryBuilderOlapGroupByPanel.tsx +1140 -0
  205. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +31 -106
  206. package/src/components/fetch-structure/QueryBuilderPostTDSPanel.tsx +69 -0
  207. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +4 -1
  208. package/src/components/fetch-structure/QueryBuilderTDSComponentHelper.tsx +118 -0
  209. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +4 -23
  210. package/src/components/shared/LambdaEditor.tsx +25 -22
  211. package/src/components/workflows/ServiceQueryBuilder.tsx +10 -2
  212. package/src/graphManager/QueryBuilderHashUtils.ts +16 -0
  213. package/src/graphManager/QueryBuilderSupportedFunctions.ts +7 -0
  214. package/src/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +14 -0
  215. package/src/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +129 -0
  216. package/src/stores/QueryBuilderStateBuilder.ts +14 -1
  217. package/src/stores/QueryBuilderStateTestUtils.ts +9 -13
  218. package/src/stores/QueryBuilderTypeaheadHelper.ts +2 -2
  219. package/src/stores/explorer/QueryBuilderExplorerState.ts +3 -3
  220. package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +4 -0
  221. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +2 -1
  222. package/src/stores/fetch-structure/tds/QueryBuilderTDSColumnState_.ts +28 -0
  223. package/src/stores/fetch-structure/tds/QueryBuilderTDSHelper.ts +79 -0
  224. package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +68 -1
  225. package/src/stores/fetch-structure/tds/QueryResultSetModifierState.ts +2 -2
  226. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregateOperator.ts +1 -1
  227. package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.ts +11 -9
  228. package/src/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByOperatorLoader.ts +39 -0
  229. package/src/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByState.ts +377 -0
  230. package/src/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByStateBuilder.ts +237 -0
  231. package/src/stores/fetch-structure/tds/olapGroupBy/QueryBuilderOlapGroupByValueSpecificationBuilder.ts +148 -0
  232. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_.ts +43 -0
  233. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Average.ts +56 -0
  234. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Count.ts +57 -0
  235. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Max.ts +56 -0
  236. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Min.ts +56 -0
  237. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapOperator_Sum.ts +57 -0
  238. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_AverageRank_.ts +54 -0
  239. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_DenseRank_.ts +54 -0
  240. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_Rank_.ts +54 -0
  241. package/src/stores/fetch-structure/tds/olapGroupBy/operators/QueryBuilderTDSOlapRankOperator_RowNumber_.ts +54 -0
  242. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +2 -2
  243. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +22 -10
  244. package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +11 -19
  245. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.ts +8 -7
  246. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +4 -4
  247. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +1 -1
  248. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +1 -1
  249. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +3 -3
  250. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +3 -3
  251. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +1 -1
  252. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +2 -2
  253. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +3 -3
  254. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +3 -3
  255. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.ts +1 -1
  256. package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +1 -1
  257. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts +9 -11
  258. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +1 -0
  259. package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +8 -4
  260. package/src/stores/filter/QueryBuilderFilterState.ts +7 -0
  261. package/tsconfig.json +19 -0
@@ -0,0 +1,377 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { matchFunctionName, type Type } from '@finos/legend-graph';
18
+ import {
19
+ addUniqueEntry,
20
+ deleteEntry,
21
+ guaranteeNonNullable,
22
+ hashArray,
23
+ uniq,
24
+ type Hashable,
25
+ } from '@finos/legend-shared';
26
+ import { action, makeObservable, observable } from 'mobx';
27
+ import { QUERY_BUILDER_HASH_STRUCTURE } from '../../../../graphManager/QueryBuilderHashUtils.js';
28
+ import { DEFAULT_LAMBDA_VARIABLE_NAME } from '../../../QueryBuilderConfig.js';
29
+ import type { QueryBuilderProjectionColumnDragSource } from '../projection/QueryBuilderProjectionColumnState.js';
30
+ import { QueryBuilderTDSColumnState } from '../QueryBuilderTDSColumnState_.js';
31
+ import type { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
32
+ import type { COLUMN_SORT_TYPE } from '../QueryResultSetModifierState.js';
33
+ import type { QueryBuilderTDSOlapOperator } from './operators/QueryBuilderTDSOlapOperator_.js';
34
+
35
+ export const QUERY_BUILDER_OLAP_COLUMN_DND_TYPE = 'OLAP_COLUMN';
36
+
37
+ export interface QueryBuilderOlapColumnDragSource {
38
+ columnState: QueryBuilderOlapGroupByColumnState;
39
+ }
40
+
41
+ export type QueryBuilderOlapDropTarget =
42
+ | QueryBuilderProjectionColumnDragSource
43
+ | QueryBuilderOlapColumnDragSource;
44
+
45
+ export class OlapGroupByColumnSortByState implements Hashable {
46
+ columnState: QueryBuilderTDSColumnState;
47
+ sortType: COLUMN_SORT_TYPE;
48
+
49
+ constructor(
50
+ columnState: QueryBuilderTDSColumnState,
51
+ sortType: COLUMN_SORT_TYPE,
52
+ ) {
53
+ makeObservable(this, {
54
+ columnState: observable,
55
+ sortType: observable,
56
+ setColumnState: action,
57
+ setSortType: action,
58
+ });
59
+
60
+ this.columnState = columnState;
61
+ this.sortType = sortType;
62
+ }
63
+
64
+ setColumnState(colState: QueryBuilderTDSColumnState): void {
65
+ this.columnState = colState;
66
+ }
67
+
68
+ setSortType(type: COLUMN_SORT_TYPE): void {
69
+ this.sortType = type;
70
+ }
71
+
72
+ get hashCode(): string {
73
+ return hashArray([
74
+ QUERY_BUILDER_HASH_STRUCTURE.OLAP_GROUPBY_COLUMN_SORTBY_STATE,
75
+ this.sortType,
76
+ this.columnState.columnName,
77
+ ]);
78
+ }
79
+ }
80
+
81
+ export abstract class QueryBuilderTDSOlapOperatorState implements Hashable {
82
+ readonly olapState: QueryBuilderOlapGroupByState;
83
+ lambdaParameterName: string = DEFAULT_LAMBDA_VARIABLE_NAME;
84
+ operator: QueryBuilderTDSOlapOperator;
85
+
86
+ constructor(
87
+ olapState: QueryBuilderOlapGroupByState,
88
+ operator: QueryBuilderTDSOlapOperator,
89
+ ) {
90
+ this.olapState = olapState;
91
+ this.operator = operator;
92
+ }
93
+
94
+ setLambdaParameterName(paramName: string): void {
95
+ this.lambdaParameterName = paramName;
96
+ }
97
+
98
+ setOperator(val: QueryBuilderTDSOlapOperator): void {
99
+ this.operator = val;
100
+ }
101
+
102
+ get hashCode(): string {
103
+ return hashArray([
104
+ QUERY_BUILDER_HASH_STRUCTURE.OLAP_GROUPBY_OPERATION_STATE,
105
+ this.lambdaParameterName,
106
+ this.operator,
107
+ ]);
108
+ }
109
+ }
110
+
111
+ export class QueryBuilderTDSOlapRankOperatorState extends QueryBuilderTDSOlapOperatorState {
112
+ constructor(
113
+ olapState: QueryBuilderOlapGroupByState,
114
+ operator: QueryBuilderTDSOlapOperator,
115
+ ) {
116
+ super(olapState, operator);
117
+ makeObservable(this, {
118
+ setLambdaParameterName: action,
119
+ });
120
+ }
121
+ }
122
+
123
+ export class QueryBuilderTDSOlapAggreationOperatorState extends QueryBuilderTDSOlapOperatorState {
124
+ columnState: QueryBuilderTDSColumnState;
125
+ constructor(
126
+ olapState: QueryBuilderOlapGroupByState,
127
+ operator: QueryBuilderTDSOlapOperator,
128
+ columnState: QueryBuilderTDSColumnState,
129
+ ) {
130
+ super(olapState, operator);
131
+ makeObservable(this, {
132
+ columnState: observable,
133
+ setColumnState: action,
134
+ setLambdaParameterName: action,
135
+ });
136
+ this.columnState = columnState;
137
+ }
138
+
139
+ setColumnState(val: QueryBuilderTDSColumnState): void {
140
+ this.columnState = val;
141
+ }
142
+
143
+ override get hashCode(): string {
144
+ return hashArray([
145
+ QUERY_BUILDER_HASH_STRUCTURE.OLAP_GROUPBY_AGG_OPERATION_STATE,
146
+ this.lambdaParameterName,
147
+ this.operator,
148
+ this.columnState.columnName,
149
+ ]);
150
+ }
151
+ }
152
+
153
+ export class QueryBuilderOlapGroupByColumnState
154
+ extends QueryBuilderTDSColumnState
155
+ implements Hashable
156
+ {
157
+ readonly olapState: QueryBuilderOlapGroupByState;
158
+ windowColumns: QueryBuilderTDSColumnState[] = [];
159
+ sortByState: OlapGroupByColumnSortByState | undefined;
160
+ operationState: QueryBuilderTDSOlapOperatorState;
161
+ columnName: string;
162
+
163
+ constructor(
164
+ olapState: QueryBuilderOlapGroupByState,
165
+ windowColumns: QueryBuilderTDSColumnState[],
166
+ sortType: OlapGroupByColumnSortByState | undefined,
167
+ operationState: QueryBuilderTDSOlapOperatorState,
168
+ columnName: string,
169
+ ) {
170
+ super();
171
+ makeObservable(this, {
172
+ windowColumns: observable,
173
+ sortByState: observable,
174
+ operationState: observable,
175
+ columnName: observable,
176
+ setOperatorState: observable,
177
+ setColumnName: action,
178
+ setSortBy: action,
179
+ changeWindow: action,
180
+ deleteWindow: action,
181
+ addWindow: action,
182
+ changeOperator: action,
183
+ changeSortBy: action,
184
+ });
185
+ this.olapState = olapState;
186
+ this.windowColumns = windowColumns;
187
+ this.sortByState = sortType;
188
+ this.operationState = operationState;
189
+ this.columnName = columnName;
190
+ }
191
+
192
+ get columnOlapGroupIdx(): number {
193
+ return this.olapState.olapColumns.findIndex((e) => e === this);
194
+ }
195
+
196
+ get possibleReferencedColumns(): QueryBuilderTDSColumnState[] {
197
+ // column can only reference TDS columns already defined, i.e in an earlier index of the olap columns
198
+ const idx = this.olapState.tdsState.tdsColumns.findIndex((e) => e === this);
199
+ if (idx === -1) {
200
+ return this.olapState.tdsState.tdsColumns;
201
+ }
202
+ return this.olapState.tdsState.tdsColumns.slice(0, idx);
203
+ }
204
+
205
+ get referencedTDSColumns(): QueryBuilderTDSColumnState[] {
206
+ const operatorReference =
207
+ this.operationState instanceof QueryBuilderTDSOlapAggreationOperatorState
208
+ ? [this.operationState.columnState]
209
+ : [];
210
+ const soryByReference = this.sortByState
211
+ ? [this.sortByState.columnState]
212
+ : [];
213
+ return [...this.windowColumns, ...soryByReference, ...operatorReference];
214
+ }
215
+
216
+ getColumnType(): Type | undefined {
217
+ return this.operationState.operator.getOperatorReturnType(
218
+ this.olapState.tdsState.queryBuilderState.graphManagerState.graph,
219
+ );
220
+ }
221
+
222
+ setColumnName(val: string): void {
223
+ this.columnName = val;
224
+ }
225
+
226
+ setOperatorState(op: QueryBuilderTDSOlapOperatorState): void {
227
+ this.operationState = op;
228
+ }
229
+
230
+ setSortBy(val: OlapGroupByColumnSortByState | undefined): void {
231
+ this.sortByState = val;
232
+ }
233
+
234
+ changeWindow(val: QueryBuilderTDSColumnState, idx: number): void {
235
+ this.windowColumns[idx] = val;
236
+ }
237
+
238
+ addWindow(val: QueryBuilderTDSColumnState): void {
239
+ addUniqueEntry(this.windowColumns, val);
240
+ }
241
+
242
+ deleteWindow(val: QueryBuilderTDSColumnState): void {
243
+ deleteEntry(this.windowColumns, val);
244
+ }
245
+
246
+ possibleAggregatedColumns(
247
+ op: QueryBuilderTDSOlapOperator,
248
+ ): QueryBuilderTDSColumnState[] {
249
+ if (op.isColumnAggregator()) {
250
+ return this.possibleReferencedColumns.filter((col) =>
251
+ op.isCompatibleWithColumn(col),
252
+ );
253
+ }
254
+ return [];
255
+ }
256
+
257
+ changeOperator(olapOp: QueryBuilderTDSOlapOperator): void {
258
+ const currentOperator = this.operationState.operator;
259
+ const currentAggregateColumn =
260
+ this.operationState instanceof QueryBuilderTDSOlapAggreationOperatorState
261
+ ? this.operationState.columnState
262
+ : undefined;
263
+ if (currentOperator !== olapOp) {
264
+ if (olapOp.isColumnAggregator()) {
265
+ const compatibleAggCol =
266
+ currentAggregateColumn &&
267
+ olapOp.isCompatibleWithColumn(currentAggregateColumn)
268
+ ? currentAggregateColumn
269
+ : this.possibleAggregatedColumns(olapOp)[0];
270
+ if (compatibleAggCol) {
271
+ this.setOperatorState(
272
+ new QueryBuilderTDSOlapAggreationOperatorState(
273
+ this.olapState,
274
+ olapOp,
275
+ compatibleAggCol,
276
+ ),
277
+ );
278
+ }
279
+ } else {
280
+ this.setOperatorState(
281
+ new QueryBuilderTDSOlapRankOperatorState(this.olapState, olapOp),
282
+ );
283
+ }
284
+ }
285
+ }
286
+
287
+ changeSortBy(sortOp: COLUMN_SORT_TYPE | undefined): void {
288
+ const sortByState = this.sortByState;
289
+ if (sortByState?.sortType !== sortOp) {
290
+ if (sortOp) {
291
+ const sortInfoOpState =
292
+ sortByState ??
293
+ new OlapGroupByColumnSortByState(
294
+ guaranteeNonNullable(this.possibleReferencedColumns[0]),
295
+ sortOp,
296
+ );
297
+ sortInfoOpState.setSortType(sortOp);
298
+ this.setSortBy(sortInfoOpState);
299
+ } else {
300
+ this.setSortBy(undefined);
301
+ }
302
+ }
303
+ }
304
+
305
+ get hashCode(): string {
306
+ return hashArray([
307
+ QUERY_BUILDER_HASH_STRUCTURE.OLAP_GROUPBY_COLUMN_STATE,
308
+ hashArray(this.windowColumns),
309
+ this.sortByState ?? '',
310
+ this.operationState,
311
+ this.columnName,
312
+ ]);
313
+ }
314
+ }
315
+
316
+ export class QueryBuilderOlapGroupByState implements Hashable {
317
+ readonly tdsState: QueryBuilderTDSState;
318
+ olapColumns: QueryBuilderOlapGroupByColumnState[] = [];
319
+ operators: QueryBuilderTDSOlapOperator[];
320
+ editColumn: QueryBuilderOlapGroupByColumnState | undefined;
321
+
322
+ constructor(
323
+ tdsState: QueryBuilderTDSState,
324
+ operators: QueryBuilderTDSOlapOperator[],
325
+ ) {
326
+ makeObservable(this, {
327
+ olapColumns: observable,
328
+ editColumn: observable,
329
+ addOlapColumn: action,
330
+ removeColumn: action,
331
+ moveColumn: action,
332
+ setEditColumn: action,
333
+ });
334
+ this.tdsState = tdsState;
335
+ this.operators = operators;
336
+ }
337
+
338
+ get isEmpty(): boolean {
339
+ return !this.olapColumns.length;
340
+ }
341
+
342
+ get referencedTDSColumns(): QueryBuilderTDSColumnState[] {
343
+ return uniq(this.olapColumns.map((c) => c.referencedTDSColumns).flat());
344
+ }
345
+
346
+ setEditColumn(col: QueryBuilderOlapGroupByColumnState | undefined): void {
347
+ this.editColumn = col;
348
+ }
349
+
350
+ findOperator(func: string): QueryBuilderTDSOlapOperator | undefined {
351
+ return this.operators.find((o) => matchFunctionName(func, o.pureFunc));
352
+ }
353
+
354
+ addOlapColumn(olapGroupByCol: QueryBuilderOlapGroupByColumnState): void {
355
+ addUniqueEntry(this.olapColumns, olapGroupByCol);
356
+ }
357
+
358
+ removeColumn(column: QueryBuilderOlapGroupByColumnState): void {
359
+ deleteEntry(this.olapColumns, column);
360
+ }
361
+
362
+ moveColumn(fromIndex: number, toIndex: number): void {
363
+ const fromCol = this.olapColumns[fromIndex];
364
+ const toCol = this.olapColumns[toIndex];
365
+ if (fromCol && toCol) {
366
+ this.olapColumns[fromIndex] = toCol;
367
+ this.olapColumns[toIndex] = fromCol;
368
+ }
369
+ }
370
+
371
+ get hashCode(): string {
372
+ return hashArray([
373
+ QUERY_BUILDER_HASH_STRUCTURE.OLAP_GROUPBY_STATE,
374
+ hashArray(this.olapColumns),
375
+ ]);
376
+ }
377
+ }
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ CollectionInstanceValue,
19
+ LambdaFunction,
20
+ LambdaFunctionInstanceValue,
21
+ matchFunctionName,
22
+ PrimitiveInstanceValue,
23
+ SimpleFunctionExpression,
24
+ VariableExpression,
25
+ } from '@finos/legend-graph';
26
+ import {
27
+ assertTrue,
28
+ assertType,
29
+ guaranteeIsString,
30
+ guaranteeNonNullable,
31
+ guaranteeType,
32
+ } from '@finos/legend-shared';
33
+ import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../../../graphManager/QueryBuilderSupportedFunctions.js';
34
+ import type { QueryBuilderState } from '../../../QueryBuilderState.js';
35
+ import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
36
+ import {
37
+ getTDSColumnState,
38
+ getTDSColSortTypeFromFunctionName,
39
+ } from '../QueryBuilderTDSHelper.js';
40
+ import { QueryBuilderTDSState } from '../QueryBuilderTDSState.js';
41
+ import {
42
+ type QueryBuilderTDSOlapOperatorState,
43
+ OlapGroupByColumnSortByState,
44
+ QueryBuilderOlapGroupByColumnState,
45
+ QueryBuilderTDSOlapAggreationOperatorState,
46
+ QueryBuilderTDSOlapRankOperatorState,
47
+ } from './QueryBuilderOlapGroupByState.js';
48
+
49
+ export const processTDSOlapGroupByExpression = (
50
+ expression: SimpleFunctionExpression,
51
+ queryBuilderState: QueryBuilderState,
52
+ ): void => {
53
+ // check parameters
54
+ const parametersLength = expression.parametersValues.length;
55
+ assertTrue(
56
+ parametersLength === 4 || parametersLength === 5,
57
+ `Can't process sort() expression: olapGroupBy() expects 3 or 4 argument`,
58
+ );
59
+
60
+ // expected expressions
61
+ const containsSortByExpression = parametersLength === 5;
62
+ const windowColumnsExpression = expression.parametersValues[1];
63
+ const sortByValueSpec = containsSortByExpression
64
+ ? expression.parametersValues[2]
65
+ : undefined;
66
+ const olapOperationExpression = containsSortByExpression
67
+ ? expression.parametersValues[3]
68
+ : expression.parametersValues[2];
69
+ const olapColumnExpression = containsSortByExpression
70
+ ? expression.parametersValues[4]
71
+ : expression.parametersValues[3];
72
+
73
+ // check preceding expression
74
+ const precedingExpression = guaranteeType(
75
+ expression.parametersValues[0],
76
+ SimpleFunctionExpression,
77
+ `Can't process olapGroupBy() expression: only support olapGroupBy() immediately following an expression`,
78
+ );
79
+ assertTrue(
80
+ matchFunctionName(precedingExpression.functionName, [
81
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_TAKE,
82
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DISTINCT,
83
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_SORT,
84
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
85
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY,
86
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_FILTER,
87
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.OLAP_GROUPBY,
88
+ ]),
89
+ `Can't process olapGroupBy() expression: only support olapGroupBy() in TDS expression`,
90
+ );
91
+ QueryBuilderValueSpecificationProcessor.process(
92
+ precedingExpression,
93
+ queryBuilderState,
94
+ );
95
+
96
+ // process window columns
97
+ const tdsState = guaranteeType(
98
+ queryBuilderState.fetchStructureState.implementation,
99
+ QueryBuilderTDSState,
100
+ );
101
+ assertType(
102
+ windowColumnsExpression,
103
+ CollectionInstanceValue,
104
+ `Can't process olapGroupBy() expression: olapGroupBy() expects argument #1 to be a collection`,
105
+ );
106
+ const windowColumns = windowColumnsExpression.values.map((value) => {
107
+ const columnName = guaranteeIsString(
108
+ guaranteeType(
109
+ value,
110
+ PrimitiveInstanceValue,
111
+ 'Can`t process OLAP window column expression: Column should be a primitive instance value',
112
+ ).values[0],
113
+ 'Can`t process OLAP window column expression: Column should be a string primitive instance value',
114
+ );
115
+ return getTDSColumnState(tdsState, columnName);
116
+ });
117
+
118
+ // process sortBy
119
+ let sortByState: OlapGroupByColumnSortByState | undefined;
120
+ if (containsSortByExpression) {
121
+ const sortByExpression = guaranteeType(
122
+ sortByValueSpec,
123
+ SimpleFunctionExpression,
124
+ `Can't process olapGroupBy sortBy expression: only support function expression of 'asc' or 'desc'`,
125
+ );
126
+ const sortByFunctionName = sortByExpression.functionName;
127
+ const colSortType = getTDSColSortTypeFromFunctionName(sortByFunctionName);
128
+ const colSortVal = guaranteeIsString(
129
+ guaranteeType(
130
+ sortByExpression.parametersValues[0],
131
+ PrimitiveInstanceValue,
132
+ 'Can`t process OLAP sort column : OLAP sort column should be a primitive instance value',
133
+ ).values[0],
134
+ 'Can`t process OLAP sort column: OLAP sort column should be a string primitive instance value',
135
+ );
136
+ const sortColState = getTDSColumnState(tdsState, colSortVal);
137
+ sortByState = new OlapGroupByColumnSortByState(sortColState, colSortType);
138
+ }
139
+ // process olap operation
140
+ let operatorState: QueryBuilderTDSOlapOperatorState;
141
+ if (olapOperationExpression instanceof SimpleFunctionExpression) {
142
+ assertTrue(
143
+ matchFunctionName(olapOperationExpression.functionName, [
144
+ QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_FUNC,
145
+ ]),
146
+ `Can't process olapGroupBy() operation expression: olapGroupBy() aggregation should contain function 'func'`,
147
+ );
148
+ const olapOperationExpressionParams =
149
+ olapOperationExpression.parametersValues;
150
+ const columnName = guaranteeIsString(
151
+ guaranteeType(
152
+ olapOperationExpressionParams[0],
153
+ PrimitiveInstanceValue,
154
+ 'Can`t process OLAP opperation expression: Function `func` first parameter should be a primitive instance value',
155
+ ).values[0],
156
+ 'Can`t process OLAP opperation expression: Function `func` first parameter should be a string primitive instance value',
157
+ );
158
+ const oppColumnState = getTDSColumnState(tdsState, columnName);
159
+ const operationLambda = guaranteeType(
160
+ guaranteeType(
161
+ olapOperationExpressionParams[1],
162
+ LambdaFunctionInstanceValue,
163
+ ).values[0],
164
+ LambdaFunction,
165
+ );
166
+ assertTrue(operationLambda.expressionSequence.length === 1);
167
+ const operationFunctionExp = guaranteeType(
168
+ operationLambda.expressionSequence[0],
169
+ SimpleFunctionExpression,
170
+ );
171
+ const operation = guaranteeNonNullable(
172
+ tdsState.olapGroupByState.findOperator(operationFunctionExp.functionName),
173
+ `olapGroupBy() operator '${operationFunctionExp.functionName}' not supported`,
174
+ );
175
+ operatorState = new QueryBuilderTDSOlapAggreationOperatorState(
176
+ tdsState.olapGroupByState,
177
+ operation,
178
+ oppColumnState,
179
+ );
180
+ operatorState.setLambdaParameterName(
181
+ guaranteeType(
182
+ operationLambda.functionType.parameters[0],
183
+ VariableExpression,
184
+ `Can't process olapGroupBy() operation lambda: only support olapGroupBy() operation lambda with 1 parameter of type 'VariableExpression'`,
185
+ ).name,
186
+ );
187
+ } else {
188
+ const operationLambda = guaranteeType(
189
+ guaranteeType(olapOperationExpression, LambdaFunctionInstanceValue)
190
+ .values[0],
191
+ LambdaFunction,
192
+ );
193
+ assertTrue(operationLambda.expressionSequence.length === 1);
194
+ const operationFunctionExp = guaranteeType(
195
+ operationLambda.expressionSequence[0],
196
+ SimpleFunctionExpression,
197
+ );
198
+ const operation = guaranteeNonNullable(
199
+ tdsState.olapGroupByState.findOperator(operationFunctionExp.functionName),
200
+ `olapGroupBy() operator '${operationFunctionExp.functionName}' not supported`,
201
+ );
202
+ assertTrue(
203
+ !operation.isColumnAggregator(),
204
+ `Operator '${operation.getLabel()}' expects a TDS column to aggregate against`,
205
+ );
206
+ operatorState = new QueryBuilderTDSOlapRankOperatorState(
207
+ tdsState.olapGroupByState,
208
+ operation,
209
+ );
210
+ operatorState.setLambdaParameterName(
211
+ guaranteeType(
212
+ operationLambda.functionType.parameters[0],
213
+ VariableExpression,
214
+ `Can't process olapGroupBy() operation lambda: only support olapGroupBy() operation lambda with 1 parameter of type 'VariableExpression'`,
215
+ ).name,
216
+ );
217
+ }
218
+
219
+ // main col
220
+ const olapColumnValue = guaranteeIsString(
221
+ guaranteeType(
222
+ olapColumnExpression,
223
+ PrimitiveInstanceValue,
224
+ 'Can`t process OLAP column: OLAP column should be a primitive instance value',
225
+ ).values[0],
226
+ 'Can`t process OLAP column: OLAP column should be a string primitive instance value',
227
+ );
228
+ const olapGroupByColumnState = new QueryBuilderOlapGroupByColumnState(
229
+ tdsState.olapGroupByState,
230
+ windowColumns,
231
+ sortByState,
232
+ operatorState,
233
+ olapColumnValue,
234
+ );
235
+ tdsState.olapGroupByState.addOlapColumn(olapGroupByColumnState);
236
+ tdsState.setShowOlapGroupByPanel(true);
237
+ };