You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Rick Hillegas (JIRA)" <ji...@apache.org> on 2014/02/02 22:32:08 UTC

[jira] [Updated] (DERBY-6117) Extend the Table Functions java interface to pass more query context information from Derby

     [ https://issues.apache.org/jira/browse/DERBY-6117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Hillegas updated DERBY-6117:
---------------------------------

    Attachment: derby-6117-03-aa-ArchiveVTI.diff

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)