Skip to content

Commit

Permalink
add pushdown enums to externalizeTDS queries
Browse files Browse the repository at this point in the history
  • Loading branch information
AFine-gs committed Jan 24, 2024
1 parent caa18af commit 3014410
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::pure::router::store::metamodel::clustering::*;
import meta::pure::executionPlan::featureFlag::*;
import meta::pure::dataQuality::*;
import meta::pure::executionPlan::*;
import meta::pure::extension::*;
Expand Down Expand Up @@ -143,7 +145,14 @@ function <<access.private>> meta::external::format::shared::executionPlan::exter
function <<access.private>> meta::external::format::shared::executionPlan::externalizeTDSFunctionProcessor(fe:FunctionExpression[1], state:ExternalFormatPlanGenerationState[1], extensions : Extension[*], debug:DebugContext[1]):ExecutionNode[1]
{
let parameters = $fe.parametersValues->evaluateAndDeactivate();
let children = $parameters->at(0)->processValueSpecification($state, $extensions, $debug)->toOneMany();
let fn = $parameters->at(0);
let updatedFN = if ($fn->instanceOf(ClusteredValueSpecification),
| let vs = $fn->cast(@ClusteredValueSpecification);
^$vs( exeCtx= $vs.exeCtx->toOne()->meta::pure::executionPlan::featureFlag::addFlagToContext(meta::pure::executionPlan::features::Feature.PUSH_DOWN_ENUM_TRANSFORM)); ,
|$fn
);

let children = $updatedFN->processValueSpecification($state, $extensions, $debug)->toOneMany();
let contentType = $fe.parametersValues->at(1)->byPassValueSpecificationWrapper()->cast(@InstanceValue).values->at(0)->cast(@String);
^ExternalFormatExternalizeTDSExecutionNode
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2505,3 +2505,28 @@ function <<test.Test>> meta::pure::executionPlan::tests::datetime::testPlanWithL
' )\n' +
')\n', $result->planToString($extensions));
}


function <<test.Test>> meta::pure::executionPlan::tests::testEnumPushDownWithExternalFormat():Boolean[1]
{

let extensions =meta::relational::extension::relationalExtensions() ->concatenate(meta::external::format::shared::transformation::tests::exampleExternalFormatExtension()->concatenate(meta::pure::extension::configuration::coreExtensions()));
let result = executionPlan({|Synonym.all()->project(p|$p.type, 'name')->meta::external::format::shared::functions::externalize('text/example')}, simpleRelationalMapping,meta::external::store::relational::tests::testRuntime(), $extensions);
assertEquals (
'ExternalFormat_ExternalizeTDS\n' +
'(\n' +
' type = String\n' +
' resultSizeRange = 1\n' +
' contentType = text/example\n' +
'\n' +
' (\n' +
' Relational\n' +
' (\n' +
' type = TDS[(name, String, VARCHAR(200), "")]\n'+
' resultColumns = [("name", "")]\n'+
' sql = select case when "root".TYPE = \'CUSIP\' then \'CUSIP\' when "root".TYPE = \'ISIN\' then \'ISIN\' else null end as "name" from productSchema.synonymTable as "root"\n'+
' connection = TestDatabaseConnection(type = "H2")\n'+
' )\n' +
' )\n' +
')\n', $result->planToString($extensions));
}

0 comments on commit 3014410

Please sign in to comment.