db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (DERBY-6117) Extend the Table Functions java interface to pass more query context information from Derby
Date Sun, 02 Feb 2014 21:34:08 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13889068#comment-13889068
] 

Rick Hillegas edited comment on DERBY-6117 at 2/2/14 9:32 PM:
--------------------------------------------------------------

Attaching derby-6117-03-aa-ArchiveVTI.diff. This patch adds a sample AwareVTI which we may
be able to use in user documentation. I am running tests now.

This patch introduces ArchiveVTI. This table function performs a task which many users have
found useful: ArchiveVTI unions together a main table together with a set of archive tables.
The archive tables are created at regular intervals. When a new archive table is created,
the oldest rows from the main table are moved to the archive table.

This patch also refactors ForeignTableVTI, moving its ResultSet implementaton into a new ForwardingVTI
table function. ForwardingVTI forwards its ResultSet calls to a wrapped ResultSet. ForwardingVTI
is added to the public api.


The following script shows ArchiveVTI in action:

{noformat}
connect 'jdbc:derby:memory:db;create=true';

create table t1
(
    keyCol int,
    aCol int,
    bCol int
);
create table t1_archive_001 as select * from t1 with no data;
create table t1_archive_002 as select * from t1 with no data;

insert into t1_archive_002 values ( 1, 100, 1000 ), ( 2, 200, 2000 ), ( 3, 300, 3000 );
insert into t1_archive_001 values ( 4, 400, 4000 ), ( 5, 500, 5000 ), ( 6, 600, 6000 );
insert into t1 values ( 7, 700, 7000 ), ( 8, 800, 8000 ), ( 9, 900, 9000 );

create function t1( archiveSuffix varchar( 32672 ) ) returns table
(
    keyCol int,
    aCol int,
    bCol int
)
language java parameter style derby_jdbc_result_set reads sql data
external name 'org.apache.derbyTesting.functionTests.tests.lang.ArchiveVTI.archiveVTI';

--
-- Since ArchiveVTI implements RestrictedVTI, only the indicated columns
-- will be selected from the main table and its archives. Also, the WHERE clause
-- will be pushed down into the scan of each of the tables.
--
select keyCol, bCol from table( t1( '_ARCHIVE_' ) ) s
where keyCol between 3 and 7
order by keyCol;
{noformat}



Touches the following files:

-------------------

M       java/engine/org/apache/derby/vti/ForeignTableVTI.java
A       java/engine/org/apache/derby/vti/ForwardingVTI.java
M       tools/javadoc/publishedapi.ant

Adds ForwardingVTI to the public api.

-------------------

A       java/testing/org/apache/derbyTesting/functionTests/tests/lang/ArchiveVTI.java

The new sample AwareVTI.

-------------------

M       java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java

Tests for ArchiveVTI.



was (Author: rhillegas):
Attaching derby-6117-03-aa-ArchiveVTI.diff. This patch adds a sample AwareVTI which we may
be able to use in user documentation. I am running tests now.

This patch introduces ArchiveVTI. This table function performs a task which many users have
found useful: ArchiveVTI unions together a main table together with a set of archive tables.
The archive tables are created at regular intervals. When a new archive table is created,
the oldest rows from the main table are moved to the archive table.

This patch also refactors ForeignTableVTI, moving its ResultSet implementaton into a new ForwardingVTI
table function. ForwardingVTI forwards its ResultSet calls to a wrapped ResultSet. ForwardingVTI
is added to the public api.


The following script shows ArchiveVTI in action:

connect 'jdbc:derby:memory:db;create=true';

create table t1
(
    keyCol int,
    aCol int,
    bCol int
);
create table t1_archive_001 as select * from t1 with no data;
create table t1_archive_002 as select * from t1 with no data;

insert into t1_archive_002 values ( 1, 100, 1000 ), ( 2, 200, 2000 ), ( 3, 300, 3000 );
insert into t1_archive_001 values ( 4, 400, 4000 ), ( 5, 500, 5000 ), ( 6, 600, 6000 );
insert into t1 values ( 7, 700, 7000 ), ( 8, 800, 8000 ), ( 9, 900, 9000 );

create function t1( archiveSuffix varchar( 32672 ) ) returns table
(
    keyCol int,
    aCol int,
    bCol int
)
language java parameter style derby_jdbc_result_set reads sql data
external name 'org.apache.derbyTesting.functionTests.tests.lang.ArchiveVTI.archiveVTI';

--
-- Since ArchiveVTI implements RestrictedVTI, only the indicated columns
-- will be selected from the main table and its archives. Also, the WHERE clause
-- will be pushed down into the scan of each of the tables.
--
select keyCol, bCol from table( t1( '_ARCHIVE_' ) ) s
where keyCol between 3 and 7
order by keyCol;



Touches the following files:

-------------------

M       java/engine/org/apache/derby/vti/ForeignTableVTI.java
A       java/engine/org/apache/derby/vti/ForwardingVTI.java
M       tools/javadoc/publishedapi.ant

Adds ForwardingVTI to the public api.

-------------------

A       java/testing/org/apache/derbyTesting/functionTests/tests/lang/ArchiveVTI.java

The new sample AwareVTI.

-------------------

M       java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java

Tests for ArchiveVTI.


> Extend the Table Functions java interface to pass more query context information from
Derby
> -------------------------------------------------------------------------------------------
>
>                 Key: DERBY-6117
>                 URL: https://issues.apache.org/jira/browse/DERBY-6117
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.8.3.0
>            Reporter: David Vyvyan
>              Labels: derby_triage10_11
>         Attachments: derby-6117-01-aa-AwareVTI.diff, derby-6117-01-ab-AwareVTI.diff,
derby-6117-02-aa-changeColumnNamesInStringColumnVTI.diff, derby-6117-03-aa-ArchiveVTI.diff
>
>
> General requirement is to extend the Table Functions java interface (through RestrictedVTI
or another interface) and pass more context information from Derby to Table Functions - esp
in query execution phase.
> Greater urgency is required for the first 2 items below, especially the ability to access
the original SQL which was available with VTIs. This is critical to the GaianDB project -
we extract HINTs from the query (where we pass meta data like user credentials), and also
extract full original complex predicate expressions (involving functions etc - which cannot
be expressed with a Restriction) - to push on in our query prorogation...
> In order of importance + simplicity:
> --------------------------------------------------
> 1 - Original SQL (this used to be available with VTIs through VTIEnvironment for both
compilation and execution phases)
> 2 - Name of function that was called
> 3 - User Info (ID, etc) - (this can currently be passed in the SQL hint)
> 4 - Richer predicate expressions (incl functions, etc)
> 5 - Context within Join query (e.g. inner or outer table, join type)
> 6 - Other Query Plan information
> 7 - Anything else...?



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message