Coder Social home page Coder Social logo

Comments (2)

tejeswarm avatar tejeswarm commented on May 28, 2024

In the Citus, the range table entries in a query are mocked as RTE_FUNCTION entries.

	MultiLogicalPlanCreate 
		MultiNodeTree takes { List *rangeTableList = queryTree->rtable }
			MultiTableNodeList(tableEntryList, rangeTableList);
				{ for each table in Join tableNode->referenceNames = rangeTableEntry->eref; }
                                   BaseRangeTableList
			              { RTE_FUNCTION rangeTableEntry->eref = multiTable->referenceNames; }
		                           SetRangeTblExtraData { funccolcount = list_length(rte->eref->colnames); }

Here the funccolcount gets the unaltered table's column count, i.e. 1, from the parse tree

During the runtime

AcquireRewriteLocks
   foreach(l, parsetree->rtable)
   	RTE_JOIN entry for each rte->joinaliasvars
               {rte->joinaliasvars gets the latest columns in expandRTE() -- expand the columns of a rangetable entry}
               and for each Var it calls
   	{ if (get_rte_attribute_is_dropped(curinputrte, aliasvar->varattno)) to check if any column is dropped }

This results in the ERROR as the curinputrte (RTE_FUNCTION) till has old column count in funccolcount.

ERROR: column 2 of relation "r" does not exist

This could be related to this change where we added expandRTE to accommodate dropped columns.

#4242

from citus.

tejeswarm avatar tejeswarm commented on May 28, 2024

This simple fix appears to have resolved the issue, but it may have other consequences, so we need to take a comprehensive look.

diff --git a/src/backend/distributed/utils/citus_nodefuncs.c b/src/backend/distributed/utils/citus_nodefuncs.c
index 55b83e6c5..110c61d1c 100644
--- a/src/backend/distributed/utils/citus_nodefuncs.c
+++ b/src/backend/distributed/utils/citus_nodefuncs.c
@@ -142,7 +142,16 @@ SetRangeTblExtraData(RangeTblEntry *rte, CitusRTEKind rteKind, char *fragmentSch
        fauxFunction->funcexpr = (Node *) fauxFuncExpr;

        /* set the column count to pass ruleutils checks, not used elsewhere */
+#if 0
        fauxFunction->funccolcount = list_length(rte->eref->colnames);
+#endif
+       if (rte->relid != 0)
+       {
+               Relation rel = RelationIdGetRelation(rte->relid);
+               fauxFunction->funccolcount = RelationGetNumberOfAttributes(rel);
+               RelationClose(rel);
+       }
+
        fauxFunction->funccolnames = funcColumnNames;
        fauxFunction->funccoltypes = funcColumnTypes;
        fauxFunction->funccoltypmods = funcColumnTypeMods;

from citus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.