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 drv <dr...@hotmail.com> on 2013/03/12 14:06:48 UTC
Limitations of Table Functions vs. old VTIs?
Hi - I am the principal developer of the Gaian Database which uses old style
Derby VTIs extensively.
I am currently looking at migrating to Table Functions and have hit some
problems -
1 - The main issue is that Table functions seem to require a static return
schema defined at registration time. Our VTIs return a variable (dynamic)
result schema, based on input arguments - With VTIs, Derby obtains this
through the getMetaData() method. Table functions only seem to make use of
the VTICosting and RestrictedVTI interfaces from what i can see.
2 - Is there any way that I can resolve the name of the table function at
run-time, from within the static method that implements it? I don't think a
"catalog look-up" based on my java method name would work because I intend
to have multiple table functions referencing it.
3 - I've seen no mention of Table Functions supporting the IFastPath
interface. This was useful with VTIs because it avoids the tedious job of
having to implement all the ResultSet getxxx() methods.
4 - I've yet to experiment with Table Functions properly, but one issue I
had with VTIs was that projected columns (unlike qualifiers) were not pushed
through a VIEW defined as a SELECT * on the VTI. Is this something that
would work with Table Functions now?
5 - As an aside - Neither VTIs nor Table Functions can have a SYNONYM
defined for them. This would be useful to avoid VIEW indirections when
trying to achieve a more standard syntax for querying the Table Function or
VTI (i.e. "select * from
" instead of "select * from new com.ibm.db2j....() T" or "select * from
TABLE(
(...) ) T")
Based on points 1 and 3 above - it seems to me that Table Functions are
currently a step behind what VTIs could offer before. Are there any plans to
improve them in future?
Regards
David
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.
Re: Limitations of Table Functions vs. old VTIs?
Posted by drv <dr...@hotmail.com>.
As a result of our discussion I have raised these feature requests (as
"improvements"):
https://issues.apache.org/jira/browse/DERBY-6117
=> Pass more context information from Derby to Table Functions: e.g.
Original SQL; Name of function that was called, User Info; Richer predicate
expressions, Query plan
https://issues.apache.org/jira/browse/DERBY-6118
=> Allow Table Functions to return dynamic table shapes (e.g. specified
using: "DYNAMIC RESULT SET" notation)
Other related issues (including yours from above):
https://issues.apache.org/jira/browse/DERBY-6036
https://issues.apache.org/jira/browse/DERBY-6109
https://issues.apache.org/jira/browse/DERBY-6115
Regards
David
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128275.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.
Re: Limitations of Table Functions vs. old VTIs?
Posted by drv <dr...@hotmail.com>.
Hi Rick -
My mistake with the package name requirement with 10.8. VTIs still need to
reside in "com.ibm.db2j".
I'm surprised because from memory I thought that was no longer the case... -
maybe the restriction had only omitted by mistake with some re-factoring in
an intermediary version..
Thank you for the context handle tip.. I'll give that a go for now to try
and get the info we need.
I'll raise a feature request for more info to be passed through "officially"
in future too - perhaps via an extensible structure.. e.g.
HashMap<key->Object> where keys are constants on some class and can be added
easily between releases...
Unfortunately we have no way to solve the rigid "static table shape" issue
yet...
Regards
David
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128121.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.
Re: Limitations of Table Functions vs. old VTIs?
Posted by Rick Hillegas <ri...@oracle.com>.
Hi David,
Some more responses inline...
On 3/13/13 4:30 PM, drv wrote:
> Hi Rick - yes this is useful, thanks.
>
> Just to follow up on remaining points:
>
> - Regarding the new issue (0) I inserted in my last post: Would it be
> reasonable to request some sort of extension to the Table Functions set of
> interfaces, to provide the original SQL to Table Functions at runtime (e.g.
> before the initScan())?
I think it's ok to give Derby routines extra information about their
execution context. This mechanism would not be portable to other
databases, and we would want to make that clear to application programmers.
> Perhaps another initScan() signature could be
> provided that would include the VTIEnvironment?
I would not support any further use of VTIEnvironment or VTICosting. I
don't think that they fit well with ANSI/ISO table functions.
> - Also I would be interested
> to know what purpose the "sharedState" element of the VTIEnvironment could
> have? I have not found anything I could use it for in the past...
From the code, it appears to me that sharedState is a Hashtable for
passing information between a VTI's compilation and execution phases.
> - A quick note about the "com.ibm.db2j." package requirement: We have always
> had all our VTIs under this package for the reason you stated (certainly up
> to Derby 10.5). I have discovered however that with Derby 10.8, the
> restriction is no longer there. I believe Derby will now work with VTIs from
> any package.
Interesting! My crude attempt to reproduce this behavior failed. Could
you provide an example of how this is done?
> Rick> There might be a way for the Java method to dig up one of the Derby
> contexts and find the SQL text. However, that would not be a supported api.
> => It would be very useful if there was such a "context" I could grab hold
> of. Perhaps this context would also have a reference to the original sql as
> well as the function name for that particular invocation (note the same SQL
> can trigger multiple invocations in the case of a JOIN)... Do you have any
> clues on how I might get to this? We have often hoped that the
> VTIEnvironment would act as that kind of handle...
The following code shows how to get the SQL text. Note that this is not
a supported api. It comes with no guarantees:
import java.sql.*;
import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
import org.apache.derby.iapi.sql.conn.StatementContext;
public class StatementInspector
{
public static String getStatement() throws Exception
{
Connection conn = DriverManager.getConnection(
"jdbc:default:connection" );
ContextManager contextManager = ((EmbedConnection)
conn).getContextManager();
LanguageConnectionContext lcc = (LanguageConnectionContext)
contextManager.getContext
( "LanguageConnectionContext" );
StatementContext statementContext = lcc.getStatementContext();
return statementContext.getStatementText();
}
}
> - Thanks for the tips on StringColumnVTI, for raising the SYNONYM request
> and for the info on existence of VTIs in the longer term... For now I think
> we will have to stick with VTIs for our constructs that absolutely require
> dynamic table shapes - in particular our VTI class named 'GaianQuery', which
> takes a sub-query as argument (which may be any SQL: SELECT, CRUD, Stored
> Procedure...) and which is propagated through a GaianDB network of database
> nodes and run against any set of targeted nodes.
>
> I appreciate your help. If you are interested in finding out more about the
> Gaian Database, our old research release 1.5 (from 2011) is here:
> https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=f6ce657b-f385-43b2-8350-458e6e4a344f
>
> We also have an in-house Asset release 2.1 - available on request - which
> has been significantly hardened.
Thanks!
-Rick
> Regards
> David
>
>
>
>
>
> --
> View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128096.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com.
>
Re: Limitations of Table Functions vs. old VTIs?
Posted by drv <dr...@hotmail.com>.
Hi Rick - yes this is useful, thanks.
Just to follow up on remaining points:
- Regarding the new issue (0) I inserted in my last post: Would it be
reasonable to request some sort of extension to the Table Functions set of
interfaces, to provide the original SQL to Table Functions at runtime (e.g.
before the initScan())? Perhaps another initScan() signature could be
provided that would include the VTIEnvironment? - Also I would be interested
to know what purpose the "sharedState" element of the VTIEnvironment could
have? I have not found anything I could use it for in the past...
- A quick note about the "com.ibm.db2j." package requirement: We have always
had all our VTIs under this package for the reason you stated (certainly up
to Derby 10.5). I have discovered however that with Derby 10.8, the
restriction is no longer there. I believe Derby will now work with VTIs from
any package.
Rick> There might be a way for the Java method to dig up one of the Derby
contexts and find the SQL text. However, that would not be a supported api.
=> It would be very useful if there was such a "context" I could grab hold
of. Perhaps this context would also have a reference to the original sql as
well as the function name for that particular invocation (note the same SQL
can trigger multiple invocations in the case of a JOIN)... Do you have any
clues on how I might get to this? We have often hoped that the
VTIEnvironment would act as that kind of handle...
- Thanks for the tips on StringColumnVTI, for raising the SYNONYM request
and for the info on existence of VTIs in the longer term... For now I think
we will have to stick with VTIs for our constructs that absolutely require
dynamic table shapes - in particular our VTI class named 'GaianQuery', which
takes a sub-query as argument (which may be any SQL: SELECT, CRUD, Stored
Procedure...) and which is propagated through a GaianDB network of database
nodes and run against any set of targeted nodes.
I appreciate your help. If you are interested in finding out more about the
Gaian Database, our old research release 1.5 (from 2011) is here:
https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=f6ce657b-f385-43b2-8350-458e6e4a344f
We also have an in-house Asset release 2.1 - available on request - which
has been significantly hardened.
Regards
David
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128096.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.
Re: Limitations of Table Functions vs. old VTIs?
Posted by Rick Hillegas <ri...@oracle.com>.
Hi David,
Thanks for the additional clarifications. Some more responses inline...
On 3/13/13 7:09 AM, drv wrote:
> Hi Rick - further thoughts below.
>
> (0 - New issue...)
> I have found another big issue for us by the way: It appears that Table
> Functions do not recognize the IQualifyable and Pushable interfaces anymore
> - this is understandable given that RestrictedVTI was intended to replace
> them. However, the methods on the 2 old interfaces passed a VTIEnvironment
> object which RestrictedVTI.initScan() does not. This object crucially holds
> the "orginalSQL" string which we need *at execution time* in GaianDB.
> Methods on the VTICosting interface also provide the VTIEnvironment, but
> they are only called once by Derby (and on a separate instance of the TF
> class), when it fetches stats for the table function. This means that we
> would only ever know the original SQL of the FIRST SQL query that referenced
> the table function - which is not very useful.
> By the way - we need the original SQL for many reasons: e.g.: to extract
> HINTs from it and to extract complex predicates (involving functions etc -
> which cannot be expressed with a Restriction) - through shallow parsing.
>
> Also - In response to your comments:
>
> 1)
> Rick> The static typing of table functions is a feature of the ANSI/ISO
> syntax. Each possible table shape needs to be bound by its own CREATE
> FUNCTION statement. I think you have discovered that you can hide the
> messy arguments by wrapping the table function invocations in helper
> views. You may find that varargs routines (to be introduced by Derby
> 10.10) will help you get more mileage if you want to write a single Java
> method which generates multiple, independently declared table functions.
>
> => .. yes, we already wrapped VTI invocations for standardization, e.g, for
> "logical table" LT0:
> create view LT0 as SELECT * from new com.ibm.db2j.GaianTable('LT0') T
>
> => By the way - given that this standardization approach works - why has the
> support for VTIs been removed? Does it really matter that the nasty syntax
> is available? VTIs already provide dynamic "table shapes" - which is a
> really nice feature.
IBM removed user-written VTIs from Derby before open-sourcing the code
seven years ago. I believe that user-written VTIs were removed as part
of a general effort to cull features which fell outside the SQL Standard.
Note that a backdoor was left for VTIs written by IBM. User-written VTIs
are allowed if they live in a package whose name starts with
"com.ibm.db2j." Since gaiandb is an IBM project, I think you could feel
comfortable moving your VTIs into that namespace. This may be your
quickest migration path.
> => ... and yes, there are many constructors for the GaianTable class, with
> up to 4 arguments - and yes, I already tried declaring the table function
> static method using a varargs construct ( Object... args ) which didn't
> work, so that would help with version 10.10.
>
> 2)
> Rick> Are you trying to make the single Java method smart enough to figure
> out
> at run time which table shape to return? What about giving the Java
> method an argument which encodes the table shape?
>
> => That is what I have had to do, yes - but it makes the syntax
> repetitive/nasty, e.g:
> "select * from table ( lt0('lt0') ) T" ; instead of preferred syntax:
> "select * from table ( lt0() ) T".
>
> => So is there no means of getting the table function name from inside the
> java method?
There might be a way for the Java method to dig up one of the Derby
contexts and find the SQL text. However, that would not be a supported api.
> 3)
> Rick> ... you shouldn't need to implement all of the getXXX()
> methods if you use the building-block table functions which appear in
> Derby's public api:
> org.apache.derby.vti.StringColumnVTI
> org.apache.derby.vti.VTITemplate.
>
> => .. I see what you mean - but I was referring to the methods that we
> actually USE: With IFastPath, I only had to implement ONE method. Whereas
> with ResultSet (or VTITemplate), I would need to implement/override all the
> methods we need, for all the types, as well as the next() method...
> IFastPath was really handy in avoiding this and making the code simpler to
> read/maintain.
I see. Note that if you extend StringColumnVTI, then all you have to
implement are next(), close(), and getRawColumn().
> 4)
> Rick> Restrictions are passed through views into RestrictedVTIs, but
> projections aren't yet. It's a tricky problem tracked by
> https://issues.apache.org/jira/browse/DERBY-6036.
>
> => OK. Hopefully there will be a fix for this at some point - the impact on
> memory + performance can be considerable.
+1
> 5)
> (Capability to define a SYNONYM on a table function)
> Rick> Afraid I'm not following this point. Do you need this as a workaround
> for (4) or do you have some other use case in mind?
>
> => This relates to 1) and 4). If we could define a SYNONYM for a table
> function (given a fixed set of arguments), then this could replace the
> overhead of the VIEW - and yes it would solve 4), because we would no longer
> be wrapping it with "SELECT *", e.g:
> CEATE SYNONYM LT0 for TABLE( LT0() ) T
> CEATE SYNONYM LT0_P for TABLE( LT0('with_provenance') ) T
> ...
>
> What is the feasibility of this in future?
I can't find the CREATE SYNONYM syntax in the SQL Standard. However,
Derby already supports this syntax for tables and views. I don't think
the community would push back if we extended this syntax to cover other
kinds of <table primary>. I would remove the trailing correlation name:
CREATE SYNONYM LT0 for TABLE( LT0() )
CREATE SYNONYM LT0_P for TABLE( LT0('with_provenance') )
I have logged an enhancement request for this feature:
https://issues.apache.org/jira/browse/DERBY-6109
>
> 6) (Issue from my 2nd post - conversion of a Restriction tree to a
> Qualifier[][])
> Rick> The code for converting a predicate to CNF can be found in
> org.apache.derby.impl.sql.compile.SelectNode.normExpressions()
>
> => Thank you - I'll take a look if/when I'm allowed to (!) - but I'll
> probably just code it.
>
>
> (Conclusion)
> Rick> You are welcome to file additional enhancement requests for table
> functions. We do want to make table functions even more useful.
>
> In conclusion again - the main issues are the new one (0) and 1). Next is
> issue 4), and the others are lower priority.
> What is the process to file enhancement requests?
It's very simple. Just log an Apache JIRA as described here:
http://db.apache.org/derby/derby_comm.html
> What time frame would we
> be looking at?
Depends on the enhancement. This is open source, so there are no guarantees.
> Do you expect VTIs to be removed altogether at some point?
Derby relies on a number of internal VTIs. Removing those dependencies
would be a significant hurdle for anyone who wanted to drop VTI support
altogether. No-one has expressed any interest in such a project. No-one
has expressed any interest in removing the com.ibm.db2j backdoor, either.
That said, I don't think you're going to see a lot of interest in
VTI-related bugs unless those bugs also affect the internal VTIs which
Derby uses. I would not expect a lot of support for opening the backdoor
further.
Hope this is helpful,
-Rick
>
>
>
> --
> View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128078.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com.
>
Re: Limitations of Table Functions vs. old VTIs?
Posted by drv <dr...@hotmail.com>.
Hi Rick - further thoughts below.
(0 - New issue...)
I have found another big issue for us by the way: It appears that Table
Functions do not recognize the IQualifyable and Pushable interfaces anymore
- this is understandable given that RestrictedVTI was intended to replace
them. However, the methods on the 2 old interfaces passed a VTIEnvironment
object which RestrictedVTI.initScan() does not. This object crucially holds
the "orginalSQL" string which we need *at execution time* in GaianDB.
Methods on the VTICosting interface also provide the VTIEnvironment, but
they are only called once by Derby (and on a separate instance of the TF
class), when it fetches stats for the table function. This means that we
would only ever know the original SQL of the FIRST SQL query that referenced
the table function - which is not very useful.
By the way - we need the original SQL for many reasons: e.g.: to extract
HINTs from it and to extract complex predicates (involving functions etc -
which cannot be expressed with a Restriction) - through shallow parsing.
Also - In response to your comments:
1)
Rick> The static typing of table functions is a feature of the ANSI/ISO
syntax. Each possible table shape needs to be bound by its own CREATE
FUNCTION statement. I think you have discovered that you can hide the
messy arguments by wrapping the table function invocations in helper
views. You may find that varargs routines (to be introduced by Derby
10.10) will help you get more mileage if you want to write a single Java
method which generates multiple, independently declared table functions.
=> .. yes, we already wrapped VTI invocations for standardization, e.g, for
"logical table" LT0:
create view LT0 as SELECT * from new com.ibm.db2j.GaianTable('LT0') T
=> By the way - given that this standardization approach works - why has the
support for VTIs been removed? Does it really matter that the nasty syntax
is available? VTIs already provide dynamic "table shapes" - which is a
really nice feature.
=> ... and yes, there are many constructors for the GaianTable class, with
up to 4 arguments - and yes, I already tried declaring the table function
static method using a varargs construct ( Object... args ) which didn't
work, so that would help with version 10.10.
2)
Rick> Are you trying to make the single Java method smart enough to figure
out
at run time which table shape to return? What about giving the Java
method an argument which encodes the table shape?
=> That is what I have had to do, yes - but it makes the syntax
repetitive/nasty, e.g:
"select * from table ( lt0('lt0') ) T" ; instead of preferred syntax:
"select * from table ( lt0() ) T".
=> So is there no means of getting the table function name from inside the
java method?
3)
Rick> ... you shouldn't need to implement all of the getXXX()
methods if you use the building-block table functions which appear in
Derby's public api:
org.apache.derby.vti.StringColumnVTI
org.apache.derby.vti.VTITemplate.
=> .. I see what you mean - but I was referring to the methods that we
actually USE: With IFastPath, I only had to implement ONE method. Whereas
with ResultSet (or VTITemplate), I would need to implement/override all the
methods we need, for all the types, as well as the next() method...
IFastPath was really handy in avoiding this and making the code simpler to
read/maintain.
4)
Rick> Restrictions are passed through views into RestrictedVTIs, but
projections aren't yet. It's a tricky problem tracked by
https://issues.apache.org/jira/browse/DERBY-6036.
=> OK. Hopefully there will be a fix for this at some point - the impact on
memory + performance can be considerable.
5)
(Capability to define a SYNONYM on a table function)
Rick> Afraid I'm not following this point. Do you need this as a workaround
for (4) or do you have some other use case in mind?
=> This relates to 1) and 4). If we could define a SYNONYM for a table
function (given a fixed set of arguments), then this could replace the
overhead of the VIEW - and yes it would solve 4), because we would no longer
be wrapping it with "SELECT *", e.g:
CEATE SYNONYM LT0 for TABLE( LT0() ) T
CEATE SYNONYM LT0_P for TABLE( LT0('with_provenance') ) T
...
What is the feasibility of this in future?
6) (Issue from my 2nd post - conversion of a Restriction tree to a
Qualifier[][])
Rick> The code for converting a predicate to CNF can be found in
org.apache.derby.impl.sql.compile.SelectNode.normExpressions()
=> Thank you - I'll take a look if/when I'm allowed to (!) - but I'll
probably just code it.
(Conclusion)
Rick> You are welcome to file additional enhancement requests for table
functions. We do want to make table functions even more useful.
In conclusion again - the main issues are the new one (0) and 1). Next is
issue 4), and the others are lower priority.
What is the process to file enhancement requests? What time frame would we
be looking at?
Do you expect VTIs to be removed altogether at some point?
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p128078.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.
Re: Limitations of Table Functions vs. old VTIs?
Posted by Rick Hillegas <ri...@oracle.com>.
Hi David,
Some responses inline...
On 3/12/13 6:06 AM, drv wrote:
> Hi - I am the principal developer of the Gaian Database which uses old style
> Derby VTIs extensively.
>
> I am currently looking at migrating to Table Functions and have hit some
> problems -
>
> 1 - The main issue is that Table functions seem to require a static return
> schema defined at registration time. Our VTIs return a variable (dynamic)
> result schema, based on input arguments - With VTIs, Derby obtains this
> through the getMetaData() method.
The static typing of table functions is a feature of the ANSI/ISO
syntax. Each possible table shape needs to be bound by its own CREATE
FUNCTION statement. I think you have discovered that you can hide the
messy arguments by wrapping the table function invocations in helper
views. You may find that varargs routines (to be introduced by Derby
10.10) will help you get more mileage if you want to write a single Java
method which generates multiple, independently declared table functions.
> Table functions only seem to make use of
> the VTICosting and RestrictedVTI interfaces from what i can see.
>
> 2 - Is there any way that I can resolve the name of the table function at
> run-time, from within the static method that implements it? I don't think a
> "catalog look-up" based on my java method name would work because I intend
> to have multiple table functions referencing it.
Are you trying to make the single Java method smart enough to figure out
at run time which table shape to return? What about giving the Java
method an argument which encodes the table shape?
> 3 - I've seen no mention of Table Functions supporting the IFastPath
> interface. This was useful with VTIs because it avoids the tedious job of
> having to implement all the ResultSet getxxx() methods.
Table functions don't take advantage of the IFastPath interface as far
as I know. But you shouldn't need to implement all of the getXXX()
methods if you use the building-block table functions which appear in
Derby's public api:
org.apache.derby.vti.StringColumnVTI
org.apache.derby.vti.VTITemplate.
> 4 - I've yet to experiment with Table Functions properly, but one issue I
> had with VTIs was that projected columns (unlike qualifiers) were not pushed
> through a VIEW defined as a SELECT * on the VTI. Is this something that
> would work with Table Functions now?
Restrictions are passed through views into RestrictedVTIs, but
projections aren't yet. It's a tricky problem tracked by
https://issues.apache.org/jira/browse/DERBY-6036.
> 5 - As an aside - Neither VTIs nor Table Functions can have a SYNONYM
> defined for them. This would be useful to avoid VIEW indirections when
> trying to achieve a more standard syntax for querying the Table Function or
> VTI (i.e. "select * from
> " instead of "select * from new com.ibm.db2j....() T" or "select * from
> TABLE(
> (...) ) T")
Afraid I'm not following this point. Do you need this as a workaround
for (4) or do you have some other use case in mind?
>
> Based on points 1 and 3 above - it seems to me that Table Functions are
> currently a step behind what VTIs could offer before. Are there any plans to
> improve them in future?
You are welcome to file additional enhancement requests for table
functions. We do want to make table functions even more useful.
Thanks,
-Rick
> Regards
> David
>
>
>
>
> --
> View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com.
>
Re: Limitations of Table Functions vs. old VTIs?
Posted by Rick Hillegas <ri...@oracle.com>.
Hi David,
More responses inline...
On 3/12/13 10:28 AM, drv wrote:
> I just came across another problem -
>
> The old VTIs passed predicates in a Qualifier[][] object which holds a
> representation of the predicates re-ordered in conjunctive normal form. I
> have many methods that process this Qualifier[][] structure.
When we introduced RestrictedVTI, we did not want to invent yet another
way to represent a restriction. So we considered moving Qualifier into
the public api. Unfortunately, Qualifier references DataValueDescriptor,
and that would have meant pulling a big chunk of Derby's type system
into the public api.
> Now however, the initScan() method on the RestrictedVTI interface passes
> predicates in a recursive tree of Restriction objects. The predicates in
> this structure are not re-ordered. The tree structure just matches the
> original bracketing of ANDed and ORed expressions in the query.
>
> My question is - are there any public utility methods in Derby for
> converting the top level Restriction object into a Qualifier[][]? I haven't
> found any yet. Or is there a simple way of just doing it myself?
I'm not aware of any public utility methods for doing this. The focus of
RestrictedVTI was to make it possible to deploy table functions against
generic external data sources, not against code which understands the
Derby type system and storage apis.
Writing such a utility method doesn't seem to be hard, just tedious. It
should be easy to percolate the ANDs up the Restriction structure in
order to convert to conjunctive normal form. Each
Restriction.ColumnQualifier should then correspond to a Qualifier. If
you write such a utility method, please consider donating it to the
community. The Derby code for converting a predicate to conjunctive
normal form can be found in
org.apache.derby.impl.sql.compile.SelectNode.normExpressions().
Thanks,
-Rick
> Thanks again -
> David
>
>
>
> --
> View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p127995.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com.
>
Re: Limitations of Table Functions vs. old VTIs?
Posted by drv <dr...@hotmail.com>.
I just came across another problem -
The old VTIs passed predicates in a Qualifier[][] object which holds a
representation of the predicates re-ordered in conjunctive normal form. I
have many methods that process this Qualifier[][] structure.
Now however, the initScan() method on the RestrictedVTI interface passes
predicates in a recursive tree of Restriction objects. The predicates in
this structure are not re-ordered. The tree structure just matches the
original bracketing of ANDed and ORed expressions in the query.
My question is - are there any public utility methods in Derby for
converting the top level Restriction object into a Qualifier[][]? I haven't
found any yet. Or is there a simple way of just doing it myself?
Thanks again -
David
--
View this message in context: http://apache-database.10148.n7.nabble.com/Limitations-of-Table-Functions-vs-old-VTIs-tp127988p127995.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.