Skip to content

Using bindParam on a pattern's object to bind a literal value throws OPTIC-INVALARGS Invalid Column #528

@georgeajit

Description

@georgeajit

Here is a test snippet that tries to bind a literal value to a triple pattern's object in a plan. On executing the plan, we have exception and no rows are returned. See the stack trace for exceptions seen.

public void testFromTriplesWithbindParam() throws KeyManagementException, NoSuchAlgorithmException, IOException,  SAXException, ParserConfigurationException
	{
		System.out.println("In testFromTriplesWithbindParam method");

		// Create a new Plan.
		RowManager rowMgr = client.newRowManager();
		PlanBuilder p = rowMgr.newPlanBuilder();
		PlanBuilder.Prefixer  bb = p.prefixer("http://marklogic.com/baseball/players");
		PlanBuilder.Prefixer team = p.prefixer("http://marklogic.com/mlb/team/");

		PlanParam playerIdParam  = p.param("player_id");		
		PlanParam ageParam  = p.param("player_age");
		
		PlanColumn playerNameCol = p.col("player_name");
		PlanColumn playerTeamCol = p.col("player_team");
				
		ModifyPlan player_plan = p.fromTriples(p.pattern(playerIdCol, bb.iri("age"),  ageParam),
				p.pattern(playerIdCol, bb.iri("name"), playerNameCol),
		           p.pattern(playerIdCol, bb.iri("team"), playerTeamCol));
        
		player_plan.bindParam(ageParam, p.xs.intVal(26));
		JacksonHandle jacksonHandle = new JacksonHandle();
		jacksonHandle.setMimetype("application/json");

		rowMgr.resultDoc(player_plan, jacksonHandle);
		JsonNode jsonResults = jacksonHandle.get();
		JsonNode jsonBindingsNodes = jsonResults.path("rows");
		// Should have 13 row returned.
		assertEquals("Thirteen rows not returned from testFromTriplesWithbindParam method ", 13, jsonBindingsNodes.size());
	}

Here is the stack trace:

com.marklogic.client.FailedRequestException: Local message: failed to apply resource at rows: Internal Server Error. Server Message: JS-JAVASCRIPT: fn.error(null, 'OPTIC-INVALARGS', errMsg+arg); -- Error running JavaScript request: OPTIC-INVALARGS: Invalid arguments: cannot call pattern() with invalid objects: op.param('player_age') . See the MarkLogic server error log for further detail.
	at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4237)
	at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3162)
	at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3116)
	at com.marklogic.client.impl.RowManagerImpl.resultDoc(RowManagerImpl.java:147)
	at com.marklogic.client.impl.RowManagerImpl.resultDoc(RowManagerImpl.java:126)
	at com.marklogic.client.functionaltest.TestOpticOnTriples.testFromTriplesWithbindParam(TestOpticOnTriples.java:1309)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

I have verified in the QConsole that literals can be used in the pattern in a JavaScript. Here is a similar (without binding) JS script from QConsole:

'use strict';
const op = require('/MarkLogic/optic');
      const bb = op.prefixer('http://marklogic.com/other/bball/players#');
      const tm = op.prefixer('http://marklogic.com/mlb/team/');
      const playerAgeCol = op.col('player_age');
      const playerIdCol = op.col('player_id');
      const playerNameCol = op.col('player_name');
      const playerTeamCol = op.col('player_team');
      const teamIdCol = op.col('team_id');
      const teamNameCol = op.col('team_name');
      const teamCityCol = op.col('team_city');
      const player_plan =
        op.fromTriples([
          op.pattern(playerIdCol, bb('age'), 26),
          op.pattern(playerIdCol, bb('name'), playerNameCol),
           op.pattern(playerIdCol, bb('team'), playerTeamCol)
        ], 'myPlayer', null, null, {dedup: 'off'})
        .result();
      player_plan

Templates and data files if needed can be provided.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions