@@ -153,6 +153,8 @@ static TargetEntry *placeholder_edge(cypher_parsestate *cpstate, char *name);
153
153
static TargetEntry * placeholder_traversal (cypher_parsestate * cpstate , char * name );
154
154
// call
155
155
static Query * transform_cypher_call (cypher_parsestate * cpstate , cypher_clause * clause );
156
+ // load csv
157
+ static Query * transform_cypher_load_csv (cypher_parsestate * cpstate , cypher_clause * clause );
156
158
// transform
157
159
#define PREV_CYPHER_CLAUSE_ALIAS "_"
158
160
#define CYPHER_OPT_RIGHT_ALIAS "_R"
@@ -221,6 +223,8 @@ Query *transform_cypher_clause(cypher_parsestate *cpstate, cypher_clause *clause
221
223
result = transform_cypher_sub_pattern (cpstate , clause );
222
224
} else if (is_ag_node (self , cypher_unwind )) {
223
225
result = transform_cypher_unwind (cpstate , clause );
226
+ } else if (is_ag_node (self , cypher_load_csv )) {
227
+ result = transform_cypher_load_csv (cpstate , clause );
224
228
} else {
225
229
ereport (ERROR , (errmsg_internal ("unexpected Node for cypher_clause" )));
226
230
}
@@ -328,6 +332,61 @@ static Node *transform_srf_function(cypher_parsestate *cpstate, Node *n, RangeTb
328
332
return NULL ;
329
333
}
330
334
335
+ static Query * transform_cypher_load_csv (cypher_parsestate * cpstate , cypher_clause * clause ) {
336
+ cypher_parsestate * child_cpstate = make_cypher_parsestate (cpstate );
337
+ ParseState * pstate = (ParseState * ) child_cpstate ;
338
+ cypher_load_csv * load = clause -> self ;
339
+ TargetEntry * te ;
340
+ ParseNamespaceItem * pnsi ;
341
+ FuncCall * fc = makeFuncCall (list_make2 (makeString ("postgraph" ), makeString ("cypher_load_csv" )),
342
+ list_make1 (makeString (load -> file )),
343
+ COERCE_SQL_SYNTAX ,
344
+ -1 );
345
+
346
+ Query * query = makeNode (Query );
347
+ query -> commandType = CMD_SELECT ;
348
+
349
+ /*if (clause->prev) {
350
+ int rtindex;
351
+
352
+ pnsi = transform_prev_cypher_clause(child_cpstate, clause->prev, true);
353
+ rtindex = list_length(pstate->p_rtable);
354
+ Assert(rtindex == 1); // rte is the first RangeTblEntry in pstate
355
+ query->targetList = expandNSItemAttrs(pstate, pnsi, 0, -1);
356
+ }*/
357
+
358
+ Expr * expr = NULL ;
359
+ //if (!call->where)
360
+ {
361
+ expr = transform_cypher_expr (child_cpstate , fc , EXPR_KIND_SELECT_TARGET );
362
+ //te = makeTargetEntry((Expr *) expr, (AttrNumber) pstate->p_next_resno++, call->alias, false);
363
+ te = makeTargetEntry ((Expr * ) expr , (AttrNumber ) pstate -> p_next_resno ++ , "test" , false);
364
+
365
+ expr = NULL ;
366
+ query -> targetList = lappend (query -> targetList , te );
367
+ } /*else {
368
+ pnsi = add_srf_to_query(child_cpstate, call->func, call->alias);
369
+ Node *var = scanNSItemForColumn(pstate, pnsi, 0, call->alias, -1);
370
+ te = makeTargetEntry((Expr *) var, (AttrNumber) pstate->p_next_resno++, call->alias, false);
371
+ query->targetList = lappend(query->targetList, te);
372
+
373
+ transform_entity *entity = make_transform_entity(child_cpstate, ENT_FUNC_CALL, NULL, (Node *)var, call->alias);
374
+ child_cpstate->entities = lappend(child_cpstate->entities, entity);
375
+
376
+
377
+ expr = transform_cypher_expr(child_cpstate, call->where, EXPR_KIND_WHERE);
378
+ }*/
379
+
380
+ query -> rtable = pstate -> p_rtable ;
381
+ query -> jointree = makeFromExpr (pstate -> p_joinlist , expr );
382
+ query -> hasTargetSRFs = pstate -> p_hasTargetSRFs ;
383
+
384
+ assign_query_collations (pstate , query );
385
+
386
+ free_cypher_parsestate (child_cpstate );
387
+ return query ;
388
+ }
389
+
331
390
static Query * transform_cypher_call (cypher_parsestate * cpstate , cypher_clause * clause ) {
332
391
cypher_parsestate * child_cpstate = make_cypher_parsestate (cpstate );
333
392
ParseState * pstate = (ParseState * ) child_cpstate ;
0 commit comments