From 6238f740edac8d320f61add815081d0984e5decd Mon Sep 17 00:00:00 2001 From: datomo Date: Wed, 11 Dec 2024 14:55:01 +0100 Subject: [PATCH] added some exceptions for textual alg representation --- .../org/polypheny/db/processing/AbstractQueryProcessor.java | 6 +++++- .../java/org/polypheny/db/routing/UiRoutingPageUtil.java | 6 +++++- .../java/org/polypheny/db/polyalg/PolyAlgParsingTest.java | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java b/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java index 99135b8096..da271bf051 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java +++ b/dbms/src/main/java/org/polypheny/db/processing/AbstractQueryProcessor.java @@ -277,7 +277,11 @@ private void attachPolyAlgPlan( AlgNode alg ) { InformationPolyAlg infoPolyAlg = new InformationPolyAlg( group, jsonString, PlanType.LOGICAL ); if ( shouldAttachTextualPolyAlg() ) { // when testing, we want to access the human-readable form - infoPolyAlg.setTextualPolyAlg( alg.buildPolyAlgebra( (String) null ) ); + String serialized = alg.buildPolyAlgebra( (String) null ); + if ( serialized == null ) { + throw new GenericRuntimeException( "Could not serialize PolyAlgebra" ); + } + infoPolyAlg.setTextualPolyAlg( serialized ); } queryAnalyzer.registerInformation( infoPolyAlg ); diff --git a/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java b/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java index 44e5785386..2385ea201e 100644 --- a/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java +++ b/dbms/src/main/java/org/polypheny/db/routing/UiRoutingPageUtil.java @@ -125,7 +125,11 @@ private static void addRoutedPolyPlanPage( AlgNode routedNode, InformationManage queryAnalyzer.addGroup( group ); InformationPolyAlg infoPolyAlg = new InformationPolyAlg( group, jsonString, isPhysical ? PlanType.PHYSICAL : PlanType.ALLOCATION ); if ( attachTextualPlan ) { - infoPolyAlg.setTextualPolyAlg( routedNode.buildPolyAlgebra( (String) null ) ); + String serialized = routedNode.buildPolyAlgebra( (String) null ); + if ( serialized == null ) { + throw new GenericRuntimeException( "Unable to serialize routing plan" ); + } + infoPolyAlg.setTextualPolyAlg( serialized ); } queryAnalyzer.registerInformation( infoPolyAlg ); } diff --git a/dbms/src/test/java/org/polypheny/db/polyalg/PolyAlgParsingTest.java b/dbms/src/test/java/org/polypheny/db/polyalg/PolyAlgParsingTest.java index e69b906d64..08de0e9164 100644 --- a/dbms/src/test/java/org/polypheny/db/polyalg/PolyAlgParsingTest.java +++ b/dbms/src/test/java/org/polypheny/db/polyalg/PolyAlgParsingTest.java @@ -79,12 +79,12 @@ public class PolyAlgParsingTest { private static final String GRAPH_NAME = "polyAlgGraph"; private static final String DOC_NAME = MqlTestTemplate.namespace; private static final String DOC_COLL = "polyalgdocs"; - private static TestHelper testHelper; @BeforeAll public static void start() throws SQLException { - testHelper = TestHelper.getInstance(); + //noinspection ResultOfMethodCallIgnored + TestHelper.getInstance(); addTestData(); } @@ -197,7 +197,7 @@ private static void testQueryRoundTrip( String query, QueryLanguage ql, String n } for ( Information info : transaction.getQueryAnalyzer().getInformationArray() ) { - if ( info instanceof InformationPolyAlg polyInfo ) { + if ( info instanceof InformationPolyAlg polyInfo && polyInfo.getTextualPolyAlg() != null ) { switch ( PlanType.valueOf( polyInfo.planType ) ) { case LOGICAL -> logical = polyInfo.getTextualPolyAlg(); case ALLOCATION -> allocation = polyInfo.getTextualPolyAlg();