[teiid-issues] [JBoss JIRA] (TEIID-4928) Couchbase - NAMEINSOURCE required for all the columns and tables

Juraj Duráni (JIRA) issues at jboss.org
Thu May 25 03:01:00 EDT 2017


    [ https://issues.jboss.org/browse/TEIID-4928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13411704#comment-13411704 ] 

Juraj Duráni commented on TEIID-4928:
-------------------------------------

> Can you provide more details, like the exception, from a failing case?
There Is not exception. I received no result (not single row). With NAMEINSOURCE, I got correct result.

> Perhaps it would be possible to provide N1QL queries to pull a representative docs in addition to or instead of limit based sampling.
That would make more sense to me, but still there is a lot of catches for which defining metadata manually would be better (sparse data, not all possible attributes present in current documents, renaming, moving buckets...). So custom N1QL query is a good option, but I would not discourage user from defining metadata manually.

> ... for a column in teiid table to map to this kinds of attr in document, the NAMEINSOURCE is necessary.
I believe you have disproved this by yourself:
{quote}
teiid load metadata will create metadata aotomaticly, because each of columns represent a attr in a json document
{quote}
If Teiid is able to do mapping *JSON attribute --> Teiid column* during metadata loading without anything else, why it is not able to map it the other way round? I.e. *Teiid column --> JSON attribute*. In fact, during metadata load e.g. JSON attribute *myAttribute* is mapped to Teiid column *myAttribute*. Why Teiid cannot do the same while mapping Teiid column *myColumn* to attribute *myColumn*? I think, that Teiid should assume, that column name and attribute name is mapped 1-to-1 in both ways by default. Only if it is not true, then user needs to define NAMEINSOURCE.

> The table name map to keyspace name in couchbase...
This does not make sense to me. Why is table name mapped to keyspace and then there is *teiid_couchbase:NAMEDTYPEPAIR* which defines *attribute:table_name* pair? Moreover, keyspace is defined twice - first in resource-adapter definition, second in metadata. For me it would make more sense this:
# Define namespace and keyspace in resource-adapter definition
# For each table, define name of the attribute which determines table - e.g.:
{code:sql}
CREATE FOREIGN TABLE MyTable(....) OPTIONS ("teiid_couchbase:NAMEDTYPE" 'type')
{code}
# Now, N1QL could look like:
{code:sql}
SELECT ... FROM `<keyspace-from-resource-adapter>` `$cb_t1` LET ... WHERE `$cb_t1`.`<attribute-name-from-options>` = '<name-of-the-table>'
{code}
E.g.
{code:sql}
SELECT ... FROM `my_bucket` `$cb_t1` LET ... WHERE `$cb_t1`.`type` = 'MyTable'
{code}

> Another reason for a table need a NAMEINSOURCE is array table...
For array tables, I understand information like NAMEINSOURCE is needed and it could be tricky. But I wonder, whether we need to mess up NAMEINSOURCE and fact that table is array table.
Here is my suggestion (consider it really only suggestion as I did not try modeling them):
# Currently, there are two information that table is an array table - it is indicated by NAMEINSOURCE and teiid_couchbase:ISARRAYTABLE option.
# How about using only option
## change *teiid_couchbase:ISARRAYTABLE* to *teiid_couchbase:ARRAYTABLE*
## change type from boolean to string (with values like *nested\[\]\[\]*)
## if the option *IS NOT* present, consider table to be a regular table
## if the option *IS* present, consider table to be an array table and use value just like you use NAMEINSOURCE now

What do you think? Does it make sense?

> Couchbase - NAMEINSOURCE required for all the columns and tables
> ----------------------------------------------------------------
>
>                 Key: TEIID-4928
>                 URL: https://issues.jboss.org/browse/TEIID-4928
>             Project: Teiid
>          Issue Type: Bug
>          Components: Misc. Connectors
>    Affects Versions: 9.3
>            Reporter: Juraj Duráni
>            Assignee: Kylin Soong
>
> Option *NAMEINSOURCE* is de facto required for all the columns and tables. If it is not present then:
> # column name in source query is not enclosed in back quotes - e.g. *`$cb_t1`.ShortValue* instead of *`$cb_t1`.`ShortValue`*
> # name of the table is not added to the source query - e.g. *SELECT ... FROM null `$cb_t1` LET ... WHERE ...* instead of *SELECT ... FROM `smalla` `$cb_t1` LET ... WHERE ...*
> This should work OOB without need to add NAMEINSOURCE option. Teiid should automatically translate column name from e.g. *MyColumn* to *`MyColumn`* if option is not set. Same with name of the table.
> In case of table I think this is more serious as it does not even try name of the table but supplies *null* to the query



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)



More information about the teiid-issues mailing list