Skip to content

Commit

Permalink
Support from() without mapping on ES queries (#2786)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbey authored Apr 16, 2024
1 parent bebd0ad commit a4957fe
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,33 @@ function meta::pure::router::clustering::cluster(v:ValueSpecification[1], mappin
v:VariableExpression[1]|print(if($debug.debug,|$v->asString()->debug($debug.space+'Var: '),|''));
^ClusterResponse(cluster=$v);,
c:StoreMappingClusteredValueSpecification[1] | ^ClusterResponse(cluster = $c),
t:TDSRoutedValueSpecification[1] | ^ClusterResponse(cluster = ^StoreMappingClusteredValueSpecification(
genericType = $t.genericType,
multiplicity = $t.multiplicity,
s = $extensions->meta::pure::extension::storeContractFromStore($t.store),
store = $t.store,
mapping = $t.mapping,
runtime = $t.runtime,
openVars = $openVariables,
val = $t,
exeCtx = $t.executionContext,
executable = true
)),
t:TDSRoutedValueSpecification[1] |
let cluster = if ($t.mapping->isEmpty(),
| ^StoreClusteredValueSpecification(
genericType = $t.genericType,
multiplicity = $t.multiplicity,
s = $extensions->meta::pure::extension::storeContractFromStore($t.store),
store = $t.store,
runtime = $t.runtime,
openVars = $openVariables,
val = $t,
exeCtx = $t.executionContext,
executable = true
),
| ^StoreMappingClusteredValueSpecification(
genericType = $t.genericType,
multiplicity = $t.multiplicity,
s = $extensions->meta::pure::extension::storeContractFromStore($t.store),
store = $t.store,
mapping = $t.mapping->toOne(),
runtime = $t.runtime,
openVars = $openVariables,
val = $t,
exeCtx = $t.executionContext,
executable = true
)
);
^ClusterResponse(cluster = $cluster);,
s:StoreRoutedValueSpecification[1]|
let processed = $s.value->cluster([], $openVariables, $s.executionContext, ^$debug(space = $debug.space+' '), $analyticsDecision, $extensions);
if ($processed.cluster->instanceOf(StoreClusteredValueSpecification),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Class meta::pure::router::TDSRoutedValueSpecification extends RoutedValueSpecifi
{
id:String[1];
runtime:Runtime[1];
mapping:Mapping[1];
mapping:Mapping[0..1];
store:meta::pure::store::Store[1];
executionContext:meta::pure::runtime::ExecutionContext[1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ function meta::external::store::elasticsearch::v7::contract::routeFunctionExpres
fe:FunctionExpression[1] | $fe.func == meta::external::store::elasticsearch::v7::tds::indexToTDS_Elasticsearch7Store_1__String_1__TabularDataSet_1_,
{function: Function<Any>[1], fe: FunctionExpression[1], state: RoutingState[1], executionContext: meta::pure::runtime::ExecutionContext[1], vars: Map<VariableExpression, ValueSpecification>[1], inScopeVars: Map<String, List<Any>>[1], extensions: meta::pure::extension::Extension[*], debug: DebugContext[1] |
let store = $fe->instanceValuesAtParameter(0, $vars, $inScopeVars)->toOne()->cast(@Elasticsearch7Store);
let mapping = $state.routingStrategy->cast(@meta::pure::router::store::metamodel::StoreMappingRoutingStrategy).mapping;
let runtime = $state.routingStrategy->cast(@meta::pure::router::store::metamodel::StoreMappingRoutingStrategy).runtime;
let mapping = if($state.routingStrategy->instanceOf(meta::pure::router::store::metamodel::StoreMappingRoutingStrategy),
|$state.routingStrategy->cast(@meta::pure::router::store::metamodel::StoreMappingRoutingStrategy).mapping,
|[]
);
let runtime = $state.routingStrategy->cast(@meta::pure::router::store::metamodel::StoreRoutingStrategy).runtime;
^$state(value = ^TDSRoutedValueSpecification(
genericType = $fe.genericType,
multiplicity = $fe.multiplicity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function meta::external::store::elasticsearch::executionTest::testCase::tds::run
let toCompile = $config.model->replace('%_url_%', 'http://%s:%d'->format([$url.host, $url.port])) + '\n\n' +
'###Pure \n\n ' +
'function test::test(' + $varDefinitions + '): TabularDataSet[1] {\n' +
' indexToTDS(test::Store, \'omdb-common\')->from(test::EmptyMapping, test::Runtime)->' + $toTest + ';' +
' indexToTDS(test::Store, \'omdb-common\')->from(test::Runtime)->' + $toTest + ';' +
'}';

// $toCompile->println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,4 @@ Runtime test::Runtime
connection: test::Connection
]
];
}

###Mapping
Mapping test::EmptyMapping
(

)
}

0 comments on commit a4957fe

Please sign in to comment.