Sonia,

ModifiableTable seems to be the right approach. There’s probably something 
subtle preventing it from working.

My guess is that the problem is that you have a EnumerableTableModificationRel 
(enumerable convention) whose child is ValuesRel (none aka logical convention). 
To find a useful plan, you need to find implementations of all nodes in 
something other than logical convention. In this case, the child needs to be of 
enumerable convention.

See how JdbcTableModificationRule.convert calls 'convert(modify.getChild(), 
traitSet)’ with the child del it passes to new JdbcTableModificationRel( … )? 
You should probably also call convert before passing a del to new 
EnumerableTableModificationRel.

When you have it successfully calling EnumerableTableModificationRel.implement 
you’re almost there. Then the challenge will be to generate the appropriate 
code to (I presume) modify the .csv file.

Julian


On Sep 30, 2014, at 1:28 PM, Garcia, Sonia <[email protected]> wrote:

> Dear Julian,
> 
> I am trying to add DML operations support to the csv-optiq project, but so 
> far I couldn't make it work. In a previous  Mongo-optiq post I saw your 
> suggestion about implementing ModifiableTable. So This is exactly what I am 
> doing in the  CsvTable class.
> 
> However, when I am trying to run this query:
> 
> 0: jdbc:optiq:model=target/test-classes/model> insert into "DEPTS" ("DEPTNO", 
> "N
> AME") values(19, 'test');
> 
> I keep getting a bunch  of errors (see below). Is there anything else I 
> should do? I couldn't find any examples using this ModifiableTable, so if you 
> could point me to any, it  would be very helpful.
> 
> Thanks in advance,
> 
> Sonia
> 
> Error: while executing SQL: insert into "DEPTS" ("DEPTNO", "NAME") values(19, 
> 'test') (state=,code=0)
> java.sql.SQLException: while executing SQL: insert into "DEPTS" ("DEPTNO", 
> "NAME
> ") values(19, 'test')
>        at net.hydromatic.avatica.Helper.createException(Helper.java:39)
>        at 
> net.hydromatic.avatica.AvaticaStatement.execute(AvaticaStatement.java
> :70)
>        at sqlline.Commands.execute(Commands.java:822)
>        at sqlline.Commands.sql(Commands.java:732)
>        at sqlline.SqlLine.dispatch(SqlLine.java:808)
>        at sqlline.SqlLine.begin(SqlLine.java:681)
>        at sqlline.SqlLine.start(SqlLine.java:398)
>        at sqlline.SqlLine.main(SqlLine.java:292)
> Caused by: org.eigenbase.relopt.RelOptPlanner$CannotPlanException: Node 
> [rel#227
> :Subset#1.ENUMERABLE.[]] could not be implemented; planner state:
> 
> Root: rel#227:Subset#1.ENUMERABLE.[]
> Original rel:
> EnumerableTableModificationRel(subset=[rel#227:Subset#1.ENUMERABLE.[]], 
> table=[[SALES, DEPTS]], operation=[INSERT], updateColumnList=[[]], 
> flattened=[true]): rowcount = 1.0, cumulative cost = {1.0 rows, 0.0 cpu, 0.0 
> io}, id = 226
>  ValuesRel(subset=[rel#225:Subset#0.NONE.[]], tuples=[[{ 19, 'test' }]]): 
> rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 223
> 
> Sets:
> Set#0, type: RecordType(INTEGER DEPTNO, VARCHAR NAME)
>        rel#225:Subset#0.NONE.[], best=null, importance=0.9
>                rel#223:ValuesRel.NONE.[](type=RecordType(INTEGER DEPTNO, 
> VARCHAR NAME),tuples=[{ 19, 'test' }]), rowcount=1.0, cumulative cost={inf}
>        rel#230:Subset#0.ENUMERABLE.[], best=rel#229, importance=0.45
>                
> rel#231:AbstractConverter.ENUMERABLE.[](child=rel#225:Subset#0.NONE.[],convention=ENUMERABLE,sort=[]),
>  rowcount=1.0, cumulative cost={inf}
>                
> rel#229:EnumerableValuesRel.ENUMERABLE.[](type=RecordType(INTEGER DEPTNO, 
> VARCHAR NAME),tuples=[{ 19, 'test' }]), rowcount=1.0, cumulative cost={1.0 
> rows, 1.0 cpu, 0.0 io}
> Set#1, type: RecordType(BIGINT ROWCOUNT)
>        rel#227:Subset#1.ENUMERABLE.[], best=null, importance=1.0
>                
> rel#226:EnumerableTableModificationRel.ENUMERABLE.[](child=rel#225:Subset#0.NONE.[],table=[SALES,
>  DEPTS],operation=INSERT,updateColumnList=[],flattened=true), rowcount=1.0, 
> cumulative cost={inf}
> 
> 
>        at 
> org.eigenbase.relopt.volcano.RelSubset$CheapestPlanReplacer.visit(Rel
> Subset.java:444)
>        at 
> org.eigenbase.relopt.volcano.RelSubset.buildCheapestPlan(RelSubset.ja
> va:286)
>        at 
> org.eigenbase.relopt.volcano.VolcanoPlanner.findBestExp(VolcanoPlanne
> r.java:676)
>        at net.hydromatic.optiq.tools.Programs$5.run(Programs.java:234)
>        at 
> net.hydromatic.optiq.tools.Programs$SequenceProgram.run(Programs.java
> :282)
> http://www.bgcpartners.com
> CONFIDENTIAL: This e-mail has been sent to you by one of the BGC entities 
> (collectively BGC)
> listed at the following link 
> http://www.bgcpartners.com/legal/disclaimers/index.html#email_disclaimer.
> The link contains company and FCA registration numbers. This e-mail, 
> including its contents and
> attachments, if any, are confidential. If you are not the named recipient 
> please notify the sender and
> immediately delete it. You may not disseminate, distribute, or forward this 
> e-mail message or disclose
> its contents to anybody else. Copyright and any other intellectual property 
> rights in its contents are the
> sole property of BGC and its affiliates. E-mail transmission cannot be 
> guaranteed to be secure or error-free.
> The sender therefore does not accept liability for any errors or omissions in 
> the contents of this
> message which arise as a result of e-mail transmission.  If verification is 
> required please request a
> hard-copy version. Although we routinely screen for viruses, addressees 
> should check this e-mail and any
> attachments for viruses. We make no representation or warranty as to the 
> absence of viruses in this
> e-mail or any attachments. Please note that to ensure regulatory compliance 
> and for the protection of our
> customers and business, we may monitor and read e-mails sent to and from our 
> server(s). 
> The registered offices of the BGC entities are at 1 Churchill Place, London, 
> E14 5RD.  
> For any issues arising from this email please reply to the sender. 
> The FCA register appears at http://www.FCA.org.uk/register/.  
> The FCA regulates the financial services industry in the United Kingdom and 
> is located at 
> 25 The North Colonnade, Canary Wharf, London, E14 5HS.
> BGC Financial LP CFTC Rule 1.55(K) Firm Specific Disclosure Statement: 
> http://www.bgcpartners.com/futuresdisclosures/

Reply via email to