... |
| TrimStrings | true to trim trailing whitespace from fixed length character strings. Note that Teiid only has a string, or varchar, type that treats trailing whitespace as meaningful. | false | | UseBindVariables | true to indicate that PreparedStatements should be used and that literal values in the source query should be replace with bind variables. If false only LOB values will trigger the use of PreparedStatements. | true | |
| UseCommentsInSourceQuery | This will embed a /\*comment*/ leading comment with session/request id in source SQL query for informational purposes | false | |
| MaxPreparedInsertBatchSize | The max size of a prepared insert batch. | 2048 | |
... |
| procedurePatternName | See DatabaseMetaData.getProcedures \[1\] | null | | tableTypes | Comma separated list - without spaces - of imported table types. See DatabaseMetaData.getTables \[1\] | null | |
| excludeTables | A case-insensitive regular expression that when matched against a fully qualified Teiid table name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?\!<inclusion pattern>).\* to act as an inclusion filter. | null | | excludeProcedures | A case-insensitive regular expression that when matched against a fully qualified Teiid procedure name will exclude it from import. Applied after procedure names are retrieved. Use a negative look-ahead (?\!<inclusion pattern>).\* to act as an inclusion filter. | null | | useFullSchemaName | When false, directs the importer to drop the source catalog/schema from the Teiid object name, so that the Teiid fully qualified name will be in the form of <model name>.<table name> - Note: that when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. This option does not affect the name in source property. | true | |
| importKeys | true to import primary and foreign keys | true | | importIndexes | true to import index/unique key/cardinality information | true | |
... |
| quoteNameInSource | false will override the default and direct Teiid to create source queries using unquoted identifiers. | true | | useProcedureSpecificName | true will allow the import of overloaded procedures (which will normally result in a duplicate procedure error) by using the unique procedure specific name as the Teiid name. This option will only work with JDBC 4.0 compatible drivers that report specific names. | false | |
| useCatalogName | true will use any non-null/non-empty catalog name as part of the name in source, e.g. "catalog"."schema"."table"."column", and in the Teiid runtime name if useFullSchemaName is also true. false will not use the catalog name in either the name in source or the Teiid runtime name. Should be set to false for sources that do not fully support a catalog concept, but return a non-null catalog name in their metadata - such as HSQL. | true | |
| useQualifiedName | true will use name qualification for both the Teiid name and name in source as dictated by the useCatalogName and useFullSchemaName properties. Set to false to disable all qualification for both the Teiid name and the name in source, which effectively ignores the useCatalogName and useFullSchemaName properties. Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. | true\\ | |
|
... |
|
{warning:title=Warning}The default import settings will crawl all available metadata. This import process is time consuming and full metadata import is not needed in most situations. Most commonly you'll want to limit the import by at least schemaPattern and tableTypes. |
{warning} |
... |
A Translator is typically paired with a particular JCA resource adapter. In instances where pooling, environment dependent configuration management, advanced security handling, etc. are not needed, then a JCA resource adapter is not needed. The configuration of JCA ConnectionFactories for needed resource adapters is not part of this guide, please see the Teiid Administrator Guide and the kit examples for configuring resource adapters for use in JBossAS.
Translators can have a number of configurable properties. These are broken down into execution properties, which determine aspects of how data is retrieved, and import settings, which determine what metadata is read for import.
The execution properties for a translator typically have reasonable defaults. For specific translator types, e.g. the Derby translator, base execution properties are already tuned to match the source. In most cases the user will not need to adjust their values.
Base Execution Properties - shared by all translators
Name | Description | Default |
---|---|---|
Immutable | Set to true to indicate that the source never changes. | false |
RequiresCriteria | Set to true to indicate that source SELECT/UPDATE/DELETE queries require a where clause. | false |
SupportsOrderBy | Set to true to indicate that the ORDER BY clause is supported. | false |
SupportsOuterJoins | Set to true to indicate that OUTER JOINs are supported. | false |
SupportsFullOuterJoins | If outer joins are supported, true indicates that FULL OUTER JOINs are supported. | false |
SupportsInnerJoins | Set to true to indicate that INNER JOINs are supported. | false |
SupportedJoinCriteria | If joins are supported, defines what criteria may be used as the join criteria. May be one of (ANY, THETA, EQUI, or KEY). | ANY |
MaxInCriteriaSize | If in criteria are supported, defines what the maximum number of in entries are per predicate. -1 indicates no limit. | -1 |
MaxDependentInPredicates | If in criteria are supported, defines what the maximum number of predicates that can be used for a dependent join. Values less than 1 indicate to use only one in predicate per dependent value pushed (which matches the pre-7.4 behavior). | -1 |
NativeQueryProcedureName | if the native query is supported on the translator, this property indicates the name of the procedure. | native |
SupportsNativeQueries | Set to true to indicate the translator supports the direct execution of commands using the native procedure | false |
Only a subset of the supports metadata can be set through execution properties. If more control is needed, please consult the Developer's Guide. |
There are no base importer settings.
For all the translators to override Execution Properties can be configured in the vdb.xml file.
<translator type="oracle-override" name="oracle"> <property value="RequiresCriteria" name="true"/> </translator>
The above XML fragment is overriding the oracle translator and altering the behavior of RequiresCriteria property to true. Note that the modified translator is only available in the scope of this VDB.
In some situations the teiid_rel:native-query property and native procedures accept parameterizable strings that can positionally reference IN parameters. A parameter reference has the form $integer, i.e. $1 Note that 1 based indexing is used and that only IN parameters may be referenced. Dollar-sign integer is therefore reserved, but may be escaped with another $, i.e. $$1. The value will be bound as a prepared value or a literal is a source specific manner. The native query must return a result set that matches the expectation of the calling procedure.
For example the native-query "select c from g where c1 = $1 and c2 = '$$1'" results in a JDBC source query of "select c from g where c1 = ? and c2 = '$1'", where ? will be replaced with the actual value bound to parameter 1.
The file translator, known by the type name file, exposes stored procedures to leverage file system resources exposed by the file resource adapter. It will commonly be used with the TEXTTABLE or XMLTABLE table functions to use CSV or XML formatted data.
Execution Properties
Name | Description | Default |
---|---|---|
Encoding | The encoding that should be used for CLOBs returned by the getTextFiles procedure | The system default encoding |
ExceptionIfFileNotFound | Throw an exception in getFiles or getTextFiles if the specified file/directory does not exist. | true (false prior to 8.2) |
Retrieve all files as BLOBs with an optional extension at the given path.
call getFiles('path/*.ext')
If the extension path is specified, then it will filter all of the file in the directory referenced by the base path. If the extension pattern is not specified and the path is a directory, then all files in the directory will be returned. Otherwise the single file referenced will be returned. If the path doesn't exist, then no results will be returned if ExceptionIfFileNotFound is false, otherwise an exception will be raised.
Retrieve all files as CLOB(s) with the an optional extension at the given path.
call getTextFiles('path/*.ext')
All the same files a getFiles will be retrieved, the only difference is that the results will be CLOB values using the encoding execution property as the character set.
Save the CLOB, BLOB, or XML value to given path
call saveFile('path', value)
The path should reference a new file location or an existing file to overwrite completely.
Native queries Native or direct query execution is not supported on the File Translator. |
The resource adapter for this translator provided through "File Data Source", Refer to Admin Guide for configuration information.
The JDBC translator bridges between SQL semantic and data type difference between Teiid and a target RDBMS. Teiid has a range of specific translators that target the most popular open source and proprietary databases.
Type names:* jdbc-ansi- declares support for most SQL constructs supported by Teiid, except for row limit/offset and EXCEPT/INTERCECT. Translates source SQL into ANSI compliant syntax. This translator should be used when another more specific type is not available.
set SESSION sql_mode = 'ANSI'
Execution Properties - shared by all JDBC Translators
Name | Description | Default |
---|---|---|
DatabaseTimeZone | The time zone of the database. Used when fetchings date, time, or timestamp values. | The system default time zone |
DatabaseVersion | The specific database version. Used to further tune pushdown support. | The base supported version |
TrimStrings | true to trim trailing whitespace from fixed length character strings. Note that Teiid only has a string, or varchar, type that treats trailing whitespace as meaningful. | false |
UseBindVariables | true to indicate that PreparedStatements should be used and that literal values in the source query should be replace with bind variables. If false only LOB values will trigger the use of PreparedStatements. | true |
UseCommentsInSourceQuery | This will embed a /*comment*/ leading comment with session/request id in source SQL query for informational purposes | false |
MaxPreparedInsertBatchSize | The max size of a prepared insert batch. | 2048 |
Importer Properties - shared by all JDBC Translators
Name | Description | Default |
---|---|---|
catalog | See DatabaseMetaData.getTablesFull [1] | null |
schemaPattern | See DatabaseMetaData.getTables [1] | null |
tableNamePattern | See DatabaseMetaData.getTables [1] | null |
procedurePatternName | See DatabaseMetaData.getProcedures [1] | null |
tableTypes | Comma separated list - without spaces - of imported table types. See DatabaseMetaData.getTables [1] | null |
excludeTables |
A case-insensitive regular expression that when matched against a fully qualified Teiid table name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter. | null |
excludeProcedures |
A case-insensitive regular expression that when matched against a fully qualified Teiid procedure name will exclude it from import. Applied after procedure names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter. | null |
useFullSchemaName | When false, directs the importer to drop the source catalog/schema from the Teiid object name, so that the Teiid fully qualified name will be in the form of <model name>.<table name> - Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. This option does not affect the name in source property. | true |
importKeys | true to import primary and foreign keys | true |
importIndexes | true to import index/unique key/cardinality information | true |
importApproximateIndexes | true to import approximate index information. See DatabaseMetaData.getIndexInfo [1] | true |
importProcedures | true to import procedures and procedure columns - Note that it is not always possible to import procedure result set columns due to database limitations. It is also not currently possible to import overloaded procedures. | true |
widenUnsignedTypes | true to convert unsigned types to the next widest type. For example SQL Server reports tinyint as an unsigned type. With this option enabled, tinyint would be imported as a short instead of a byte. | true |
quoteNameInSource | false will override the default and direct Teiid to create source queries using unquoted identifiers. | true |
useProcedureSpecificName | true will allow the import of overloaded procedures (which will normally result in a duplicate procedure error) by using the unique procedure specific name as the Teiid name. This option will only work with JDBC 4.0 compatible drivers that report specific names. | false |
useCatalogName | true will use any non-null/non-empty catalog name as part of the name in source, e.g. "catalog"."schema"."table"."column", and in the Teiid runtime name if useFullSchemaName is also true. false will not use the catalog name in either the name in source or the Teiid runtime name. Should be set to false for sources that do not fully support a catalog concept, but return a non-null catalog name in their metadata - such as HSQL. | true |
useQualifiedName | true will use name qualification for both the Teiid name and name in source as dictated by the useCatalogName and useFullSchemaName properties. Set to false to disable all qualification for both the Teiid name and the name in source, which effectively ignores the useCatalogName and useFullSchemaName properties. Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. | true |
[1] JavaDoc for DatabaseMetaData
Warning The default import settings will crawl all available metadata. This import process is time consuming and full metadata import is not needed in most situations. Most commonly you'll want to limit the import by at least schemaPattern and tableTypes. |
Example importer settings to only import tables and views from my-schema.
... <property name="importer.tableTypes" value="TABLE,VIEW"/> <property name="importer.schemaPattern" value="my-schema"/> ...
Usage of a JDBC source is straight-forward. Using Teiid SQL, the source may be queried as if the tables and procedures were local to the Teiid system.
Both physical tables and procedures may optionally have native queries associated with them. No validation of the native query is performed, it is simply used in a straight-forward manner to generate the source SQL. For a physical table setting the teiid_rel:native-query extension metadata will execute the native query as an inline view in the source query. This feature should only be used against sources that support inline views. The native query is used as is and is not treated as a parameterized string. For example on a physical table y with nameInSource="x" and teiid_rel:native-query="select c from g", the Teiid source query"SELECT c FROM y" would generate the SQL query "SELECT c FROM (select c from g) as x". Note that the column names in the native query must match the nameInSource of the physical table columns for the resulting SQL to be valid.
For physical procedures you may also set the teiid_rel:native-query extension metadata to a desired query string with the added ability to positionally reference IN parameters - see Parameterizable Native Queries. The teiid_rel:non-prepared extension metadata property may be set to false to turn off parameter binding. Note this option should be used with caution as inbound may allow for SQL injection attacks if not properly validated. The native query does not need to call a stored procedure. Any SQL that returns a result set positionally matching the result set expected by the physical stored procedure metadata will work. For example on a stored procedure x with teiid_rel:native-query="select c from g where c1 = $1 and c2 = '$$1'", the Teiid source query "CALL x(?)" would generate the SQL query "select c from g where c1 = ? and c2 = '$1'". Note that ? in this example will be replaced with the actual value bound to parameter 1.
This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for Override Execution Properties above. |
JDBC translator also provides a procedure with name native that gives ability to execute any ad-hoc native SQL command that is specific to an underlying source directly against the source without any Teiid parsing or resolving. The metadata of this procedure's execution results are not known to the Teiid, and they are returned as object array. User can use ARRAYTABLE construct to build a tabular output for consumption by client applications. Example execution can be like below
SELECT x.* FROM (call pm1.native('select * from g1')) w, ARRAYTABLE(w.tuple COLUMNS "e1" integer , "e2" string) AS x
SELECT x.* FROM (call pm1.native('insert into g1 (e1,e2) values (?, ?)', 112, 'foo')) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
SELECT x.* FROM (call pm1.native('update g1 set e2=? where e1 = ?','blah', 112)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
SELECT x.* FROM (call pm1.native('delete from g1 where e1 = ?', 112)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
By default the name of the procedure that executes the queries directly is called native, however user can set override execution property vdb.xml file to change it. |
The resource adapter for this translator provided through data source in JBoss AS, Refer to Admin Guide for "JDBC Data Sources" configuration section.
The LDAP translator, known by the type name ldap, exposes an LDAP directory tree relationally with pushdown support for filtering via criteria. This is typically coupled with the LDAP resource adapter.
Execution Properties
Name | Description | Default |
---|---|---|
SearchDerfaultBaseDN | Default Base DN for LDAP Searches | null |
SearchDefaultScope | Default Scope for LDAP Searches. Can be one of SUBTREE_SCOPE, OBJECT_SCOPE, ONELEVEL_SCOPE. | ONELEVEL_SCOPE |
RestrictToObjectClass | Restrict Searches to objectClass named in the Name field for a table | false |
UsePagination | Use a PagedResultsControl to page through large results. This is not supported by all directory servers. | false |
ExceptionOnSizeLimitExceeded | Set to true to throw an exception when a SizeLimitExceededException is received and a LIMIT is not properly enforced. | false |
There are no import settings for the ldap translator; it also does not provide metadata.
String columns with a default value of "multivalued-concat" will concatinate all attribute values together in alphabetical order using a ? delimiter. If a multivalued attribute does not have a default value of "multivalued-concat", then any value may be returned.
LDAP procedures may optionally have native queries associated with them - see Parameterizable Native Queries. The operation prefix (select;, insert;, update;, delete; - see the native procedure logic below for more) must be present in the native-query, but it will not be issued as part of the query to the source.
CREATE FOREIGN PROCEDURE proc (arg1 integer, arg2 string) OPTIONS ("teiid_rel:native-query" 'search;context-name=corporate;filter=(&(objectCategory=person)(objectClass=user)(!cn=$2));count-limit=5;timeout=$1;search-scope=ONELEVEL_SCOPE;attributes=uid,cn') returns (col1 string, col2 string);
Parameter values have reserved characters escaped, but are otherwise directly substituted into the query. |
This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for Override Execution Properties above. |
LDAP translator provides a procedure with name native that gives ability to execute any ad-hoc native LDAP queries directly against the source without any Teiid parsing or resolving. The metadata of this procedure's execution results are not known to the Teiid, and they are returned as object array. User can use ARRAYTABLE construct to build tabular output for consumption by client applications. Since there is no known direct query language for LDAP, Teiid exposes this procedure with a simple query structure as below
SELECT x.* FROM (call pm1.native('search;context-name=corporate;filter=(objectClass=*);count-limit=5;timeout=6;search-scope=ONELEVEL_SCOPE;attributes=uid,cn')) w, ARRAYTABLE(w.tuple COLUMNS "uid" string , "cn" string) AS x
from the above code, the "search" keyword followed by below properties. Each property must be delimited by semi-colon (;) If a property contains a semi-colon (;), it should be escaped by another semi-colon - see also Parameterizable Native Queries and the native-query procedure example above.
Name | Description | Required |
---|---|---|
context-name | LDAP Context name | Yes |
filter | query to filter the records in the context | No |
count-limit | limit the number of results. same as using LIMIT | No |
timeout | Time out the query if not finished in given milliseconds | No |
search-scope | LDAP search scope, one of SUBTREE_SCOPE, OBJECT_SCOPE, ONELEVEL_SCOPE | No |
attributes | attributes to retrieve | Yes |
SELECT x.* FROM (call pm1.native('delete;uid=doe,ou=people,o=teiid.org')) w, ARRAYTABLE(w.tuple COLUMNS "updatecount" integer) AS x
form the above code, the "delete" keyword followed the "DN" string. All the string contents after the "delete;" used as DN.
SELECT x.* FROM (call pm1.native('create;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one', 2, 3.0)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
form the above code, the "create" keyword followed the "DN" string. All the string contents after the "create;" is used as DN. It also takes one property called "attributes" which is comma separated list of attributes. The values for each attribute is specified as separate argument to the "native" procedure.
Update is similar to create
SELECT x.* FROM (call pm1.native('update;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one', 2, 3.0)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
By default the name of the procedure that executes the queries directly is called native, however user can set override execution property vdb.xml file to change it. |
The resource adapter for this translator provided through "LDAP Data Source", Refer to Admin Guide for configuration.
The Loopback translator, known by the type name loopback, provides a quick testing solution. It supports all SQL constructs and returns default results, with configurable behavior.
Execution Properties
Name | Description | Default |
---|---|---|
ThrowError | true to always throw an error | false |
RowCount | Rows returned for non-update queries. | 1 |
WaitTime | Wait randomly up to this number of milliseconds with each sourc query. | 0 |
PollIntervalInMilli | if positive results will be "asynchronously" returned - that is a DataNotAvailableException will be thrown initially and the engine will wait the poll interval before polling for the results. | -1 |
There are no import settings for the Loopback translator; it also does not provide metadata - it should be used as a testing stub.
The source connection is required for this translator
The Salesforce translator, known by the type name salesforce supports the SELECT, DELETE, INSERT and UPDATE operations against a Salesforce.com account. It is designed for use with the Teiid Salesforce resource adapter.
Name | Description | Default |
---|---|---|
ModelAuditFeilds | Audit Model Fields | false |
Execution Properties
The Salesforce translator can import metadata, but does not currently have import settings.
Salesforce does not provide the same set of functionality as a relational database. For example, Salesforce does not support arbitrary joins between tables. However, working in combination with the Teiid Query Planner, the Salesforce connector supports nearly all of the SQL syntax supported by the Teiid.
The Salesforce Connector executes SQL commands by “pushing down” the command to Salesforce whenever possible, based on the supported capabilities. Teiid will automatically provide additional database functionality when the Salesforce Connector does not explicitly provide support for a given SQL construct. In these cases, the SQL construct cannot be “pushed down” to the data source, so it will be evaluated in Teiid, in order to ensure that the operation is performed.
In cases where certain SQL capabilities cannot be pushed down to Salesforce, Teiid will push down the capabilities that are supported, and fetch a set of data from Salesforce. Then, Teiid will evaluate the additional capabilities, creating a subset of the original data set. Finally, Teiid will pass the result to the client.
SELECT sum(Reports) FROM Supervisor where Division = 'customer support';
Neither Salesforce nor the Salesforce Connector support the sum() scalar function, but they do support CompareCriteriaEquals, so the query that is passed to Salesforce by the connector will be transformed to this query.
SELECT Reports FROM Supervisor where Division = 'customer support';
The sum() scalar function will be applied by the Teiid Query Engine to the result set returned by the connector.
In some cases multiple calls to the Salesforce application will be made to support the SQL passed to the connector.
DELETE From Case WHERE Status = 'Closed';
The API in Salesforce to delete objects only supports deleting by ID. In order to accomplish this the Salesforce connector will first execute a query to get the IDs of the correct objects, and then delete those objects. So the above DELETE command will result in the following two commands.
SELECT ID From Case WHERE Status = 'Closed'; DELETE From Case where ID IN (<result of query>);
*The Salesforce API DELETE call is not expressed in SQL, but the above is an SQL equivalent expression.
It's useful to be aware of unsupported capabilities, in order to avoid fetching large data sets from Salesforce and making you queries as performant as possible. See all Supported Capabilities.
A multi-select picklist is a field type in Salesforce that can contain multiple values in a single field. Query criteria operators for fields of this type in SOQL are limited to EQ, NE, includes and excludes. The full Salesforce documentation for selecting from mullti-select picklists can be found at the following link. Querying Mulit-select Picklists
Teiid SQL does not support the includes or excludes operators, but the Salesforce connector provides user defined function definitions for these operators that provided equivalent functionality for fields of type multi-select. The definition for the functions is:
boolean includes(Column column, String param) boolean excludes(Column column, String param)
For example, take a single multi-select picklist column called Status that contains all of these values.
For that column, all of the below are valid queries:
SELECT * FROM Issue WHERE true = includes (Status, 'current, working' ); SELECT * FROM Issue WHERE true = excludes (Status, 'current, working' ); SELECT * FROM Issue WHERE true = includes (Status, 'current;working, critical' );
EQ and NE criteria will pass to Salesforce as supplied. For example, these queries will not be modified by the connector.
SELECT * FROM Issue WHERE Status = 'current'; SELECT * FROM Issue WHERE Status = 'current;critical'; SELECT * FROM Issue WHERE Status != 'current;working';
The Salesforce connector supports the calling the queryAll operation from the Salesforce API. The queryAll operation is equivalent to the query operation with the exception that it returns data about all current and deleted objects in the system.
The connector determines if it will call the query or queryAll operation via reference to the isDeleted property present on each Salesforce object, and modeled as a column on each table generated by the importer. By default this value is set to False when the model is generated and thus the connector calls query. Users are free to change the value in the model to True, changing the default behavior of the connector to be queryAll.
The behavior is different if isDeleted is used as a parameter in the query. If the isDeleted column is used as a parameter in the query, and the value is 'true' the connector will call queryAll.
select * from Contact where isDeleted = true;
If the isDeleted column is used as a parameter in the query, and the value is 'false' the connector perform the default behavior will call query.
select * from Contact where isDeleted = false;
If the option is selected when importing metadata from Salesforce, a GetUpdated procedure is generated in the model with the following structure:
GetUpdated (ObjectName IN string, StartDate IN datetime, EndDate IN datetime, LatestDateCovered OUT datetime) returns ID string
See the description of the GetUpdated operation in the Salesforce documentation for usage details.
If the option is selected when importing metadata from Salesforce, a GetDeleted procedure is generated in the model with the following structure:
GetDeleted (ObjectName IN string, StartDate IN datetime, EndDate IN datetime, EarliestDateAvailable OUT datetime, LatestDateCovered OUT datetime) returns ID string, DeletedDate datetime
See the description of the GetDeleted operation in the Salesforce documentation for usage details.
Salesforce does not support joins like a relational database, but it does have support for queries that include parent-to-child or child-to-parent relationships between objects. These are termed Relationship Queries. The SalesForce connector supports Relationship Queries through Outer Join syntax.
SELECT Account.name, Contact.Name from Contact LEFT OUTER JOIN Account on Contact.Accountid = Account.id
This query shows the correct syntax to query a SalesForce model with to produce a relationship query from child to parent. It resolves to the following query to SalesForce.
SELECT Contact.Account.Name, Contact.Name FROM Contact
select Contact.Name, Account.Name from Account Left outer Join Contact on Contact.Accountid = Account.id
This query shows the correct syntax to query a SalesForce model with to produce a relationship query from parent to child. It resolves to the following query to SalesForce.
SELECT Account.Name, (SELECT Contact.Name FROM Account.Contacts) FROM Account
See the description of the Relationship Queries operation in the SalesForce documentation for limitations.
The following are the the connector capabilities supported by the Salesforce Connector. These SQL constructs will be pushed down to Salesforce.
Salesforce procedures may optionally have native queries associated with them - see Parameterizable Native Queries. The operation prefix (select;, insert;, update;, delete; - see the native procedure logic below for more) must be present in the native-query, but it will not be issued as part of the query to the source.
CREATE FOREIGN PROCEDURE proc (arg1 integer, arg2 string) OPTIONS ("teiid_rel:native-query" 'search;SELECT ... complex SOQL ... WHERE col1 = $1 and col2 = $2') returns (col1 string, col2 string, col3 timestamp);
This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for Override Execution Properties above. |
SalesForce translator provides a procedure with name native that gives ability to execute any ad-hoc native Salesforce queries directly against the source without any Teiid parsing or resolving. The metadata of this procedure's execution results are not known to the Teiid, and they are returned as object array. User can use ARRAYTABLE construct to build a tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below
SELECT x.* FROM (call pm1.native('search;SELECT Account.Id, Account.Type, Account.Name FROM Account')) w, ARRAYTABLE(w.tuple COLUMNS "id" string , "type" string, "name" String) AS x
from the above code, the "search" keyword followed by a query statement.
The SOQL is treated as a parameterized native query so that parameter values may be inserted in the query string properly - see Parameterizable Native Queries |
SELECT x.* FROM (call pm1.native('delete;', 'id1', 'id2')) w, ARRAYTABLE(w.tuple COLUMNS "updatecount" integer) AS x
form the above code, the "delete;" keyword followed by the ids to delete as varargs.
SELECT x.* FROM (call pm1.native('create;type=table;attributes=one,two,three', 'one', 2, 3.0)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
form the above code, the "create" or "update" keyword must be followed by the following properties. Attributes must be matched positionally by the procedure variables - thus in the example attribute two will be set to 2.
Property Name | Description | Required |
---|---|---|
type | Table Name | Yes |
attributes | comma separated list of names of the columns |
The values for each attribute is specified as separate argument to the "native" procedure.
Update is similar to create, with one more extra property called "id", which defines identifier for the record.
SELECT x.* FROM (call pm1.native('update;id=pk;type=table;attributes=one,two,three', 'one', 2, 3.0)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
By default the name of the procedure that executes the queries directly is called native, however user can set override execution property vdb.xml file to change it. |
The resource adapter for this translator provided through "Salesforce Data Source", Refer to Admin Guide for configuration.
The Web Services translator, known by the type name ws, exposes stored procedures for calling web services backed by a Teiid WS resource adapter. It will commonly be used with the TEXTTABLE or XMLTABLE table functions to use CSV or XML formated data.
Setting the proper binding value on the translator is recommended as it removes the need for callers to pass an explict value. If your service is actually uses SOAP11, but the binding used SOAP12 you will receive execution failures. |
Execution Properties
Name | Description | Default |
---|---|---|
DefaultBinding | The binding that should be used if one is not specified. Can be one of HTTP, SOAP11, or SOAP12 | SOAP12 |
DefaultServiceMode | The default service mode. For SOAP, MESSAGE mode indicates that the request will contain the entire SOAP envelope and not just the contents of the SOAP body. Can be one of MESSAGE or PAYLOAD | PAYLOAD |
XMLParamName | Used with the HTTP binding (typically with the GET method) to indicate that the request document should be part of the query string. | null - unused |
There are ws importer settings, but it does provide metadata for dynamic VDBs.
The WS translator exposes low level procedures for accessing web services. See also the twitter example in the kit.
Invoke allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
Procedure invoke(binding in STRING, action in STRING, request in XML, endpoint in STRING, stream in BOOLEAN) returns XML
The binding may be one of null (to use the default) HTTP, SOAP11, or SOAP12. Action with a SOAP binding indicates the SOAPAction value. Action with a HTTP binding indicates the HTTP method (GET, POST, etc.), which defaults to POST.
A null value for the binding or endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.
Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax.
call invoke(binding=>'HTTP', action=>'GET')
The request XML should be a valid XML document or root element.
If the stream parameter is set the true, the resulting value document can only be read once. This is appropriate when directly passing the XML into XMLQUERY or XMLTABLE and only a single pass against the document is needed. If stream is null or false, then the engine may need to save a copy of the document for repeated use.
invokeHttp can return the byte contents of an HTTP(S) call.
Procedure invokeHttp(action in STRING, request in OBJECT, endpoint in STRING, stream in BOOLEAN, contentType out STRING) returns BLOB
Action indicates the HTTP method (GET, POST, etc.), which defaults to POST.
A null value for endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.
Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax.
call invokeHttp(action=>'GET')
The request can be one of SQLXML, STRING, BLOB, or CLOB. The request will be sent as the POST payload in byte form. For STRING/CLOB values this will default to the UTF-8 encoding. To control the byte encoding, see the to_bytes function.
If the stream parameter is set the true, the resulting value document can only be read once. If stream is null or false, then the engine may need to save a copy of the result for repeated use.
Native queries Native or direct query execution is not supported on the File Translator |
Theresource adapter for this translator provided through "Web Service Data Source", Refer to Admin Guide for configuration.
The OLAP Services translator, known by the type name olap, exposes stored procedures for calling analysis sevices backed by a OLAP server using MDX query lanaguage. This translator exposes a stored procedure, invokeMDX, that returns a result set containing tuple array values for a given MDX query. invokeMDX will commonly be used with the ARRAYTABLE table function to extract the results.
Since the Cube metadata exposed by the OLAP servers and relational database metadata are so different, there is no single way to map the metadata from one to other. It is best to query OLAP system using its own native MDX language through. MDX queries my be defined statically or built dynamically in Teiid's abstraction layers.
The olap translator exposes one low level procedure for accessing olap services.
invokeMdx returns a resultset of the tuples as array values.
Procedure invokeMdx(mdx in STRING, params VARIADIC OBJECT) returns table (tuple object)
The mdx parameter is a MDX query to be executed on the OLAP server.
The results of the query will be returned such that each row on the row axis will be packed into an array value that will first contain each hierarcy member name on the row axis then each measure value from the column axis.
The use of Data Roles should be considered to prevent arbitrary MDX from being submitted to the invokeMDX procedure. |
OLAP source procedures may be created using the teiid_rel:native-query extension - see Parameterizable Native Queries.
The parameter value substitution directly inserts boolean, and number values, and treats all other values as string literals. |
The procedure will invoke the native-query similar to an invokeMdx call with the benefits that the query is predetermined and that result column types are known, rather than requiring the use of ARRAYTABLE or similar functionality.
The invokeMdx procedure is the native procedure for the OLAP translator. It may be disabled or have it's name changed via the common native translator properties just like any other source. A call to a native procedure without any parameters will not attempt to parse the mdx query for parameterization. If parameters are used, the value substitution directly inserts boolean, and number values, and treats all other values as string literals.
The resource adapter for this translator provided through data source in JBoss AS, Refer to Admin Guide for "JDBC Data Sources" configuration section. Two sample -ds.xml files provided for accessing OLAP servers in teiid-examples section. One is Mondrian specific, when Mondrian server is deloyed in the same JBoss AS as Teiid (mondrian-ds.xml). To access any other OLAP servers using XMLA interface, the data source for them can be created using them example template olap-xmla-ds.xml
Think this one as a reverse to what Hibernate provides. If you have JPA based store and have a supporting object model, this translator can will reverse your object model into relational model, where you can integrate with other relational or non-relational sources.
JPA source procedures may be created using the teiid_rel:native-query extension - see Parameterizable Native Queries. The procedure will invoke the native-query similar to an native procedure call with the benefits that the query is predetermined and that result column types are known, rather than requiring the use of ARRAYTABLE or similar functionality.
This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for Override Execution Properties above. |
JPA translator provides a procedure with name native that gives ability to execute any ad-hoc native JPA-QL queries directly against the source without any Teiid parsing or resolving. Since the metadata of this procedure's execution results are not known to the Teiid and they are returned as object array. User can use ARRAYTABLE to construct a build a tabular output for consumption by client applications. Teiid exposes this procedure with a simple query structure as below
SELECT x.* FROM (call pm1.native('search;FROM Account')) w, ARRAYTABLE(w.tuple COLUMNS "id" string , "type" string, "name" String) AS x
from the above code, the "search" keyword followed by a query statement - see Parameterizable Native Queries to substitute parameter values.
SELECT x.* FROM (call pm1.native('delete;<jpa-ql>')) w, ARRAYTABLE(w.tuple COLUMNS "updatecount" integer) AS x
form the above code, the "delete" keyword followed by JPA-QL for delete operation.
SELECT x.* FROM (call pm1.native('update;<jpa-ql>')) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
form the above code, the "update" keyword must be followed by JPA-QL for the update statement.
SELECT x.* FROM (call pm1.native('create;', <entity>)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
Create operation needs to send "create" word as marker and send the entity as a the first parameter.
By default the name of the procedure that executes the queries directly is called native, however user can set override execution property vdb.xml file to change it. |
The Object translator is a bridge for reading java objects from external sources (i.e., Infinispan Cache or Map cache) and delivering them to the engine for processing. And to assist in providing that bridge, the OBJECTABLE function must be used to transform the java object into rows and columns.
The following are the translator types and their respective supported data source:
Execution Properties - infinispan-cache
Name | Description | Required | Default |
---|---|---|---|
CacheName | Identifies the name of the cache to retrieve from the Infinispan Cache Manager | Y | |
RootClassName | Indicates the type of class that should be at the root of the cache | Y | |
CacheJndiName | Specifies the Jndi reference to use to retrieve the Infinispan Cache Manager | N | |
ConfigurationFileName | Specifies the configuration file to use to create the Infinispan Cache Manager | N | |
SupportsLuceneSearching | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | N | false |
Either CacheJndiName or ConfigurationFileName must be specified so that Infinispan Cache Manager can be obtained.
Execution Properties - infinispanremote-cache
Name | Description | Required | Default |
---|---|---|---|
CacheName | Identifies the name of the cache to obtained from the Infinispan Cache Manager | Y | |
RootClassName | Indicates the type of class that should be at the root of the cache | Y | |
CacheJndiName | Specifies the Jndi reference to use when JNDI is the mechanism the data source is being made available. | N | |
RemoteServerList | Specify one or more host:ports (i.e., host:port[;host:port]) to configure in the Remote Cache Manager | N | |
ConfigurationFileName | Specifies the configuration file to use to create the Infinispan Cache Manager | N |
Either CacheJndiName, RemoteServerList or ConfigurationFileName must be specified so that Infinispan Cache Manager can be obtained.
Execution Properties - map-cache
Name | Description | Required | Default |
---|---|---|---|
RootClassName | Indicates the type of class that should be at the root of the cache | Y | |
CacheJndiName | Specifies the Jndi reference to use to retrieve the Map cache. | Y |
The following are the connector capabilities when Key Searching is used:
The following are the connector capabilities when Hibernate/Lucene Searching is enabled:
Retrieve objects from a cache and transform into rows and columns.
The following is an example of a key search. It uses a dynamic vdb to define the physical source and views using DDL. It uses a TeamObject class, shown below, with a teamName field that is used as its cache key and a String list of players.
public class TeamObject { private String teamName; private List<String> players = new ArrayList<String>(); public String getTeamName() { return teamName; } public void setTeamName(String teamName) { this.teamName = teamName; } public List<String> getPlayers() { return players; } }
Notice the use of the OBJECTABLE function to parse the object from Team and transform into rows and column. This metadata could also be defined by using Teiid Designer.
<vdb name="team" version="1"> <description>Shows how to call a remoteInfinispan Cache</description> <property name="UseConnectorMetadata" value="cached" /> <model name="Team" visible="false"> <source name="objsource" translator-name="infinispan1" /> <metadata type="DDL"><![CDATA[ CREATE FOREIGN TABLE Team (TeamObject Object OPTIONS (NAMEINSOURCE 'this', SEARCHABLE 'Unsearchable'), teamName varchar(255) PRIMARY KEY); ]]> </metadata> </model> <model name="TeamView" type="VIRTUAL"> <metadata type="DDL"><![CDATA[ CREATE VIEW Players ( TeamName varchar(255) PRIMARY KEY, PlayerName varchar(255) ) AS SELECT t.TeamName, y.Name FROM Team as T, OBJECTTABLE('m.players' PASSING T.TeamObject as m COLUMNS Name string 'teiid_row') as y; ]]> </metadata> </model> <translator name="infinispan1" type="infinispanremote-cache"> <property name="CacheName" value="teams"/> <property name="RootClassName" value="com.jboss.datagrid.hotrod.Team"/> <property name="RemoteServerList" value="localhost:11222"/> <!-- optional properties for obtaining the RemoteCacheManager --> <!-- <property name="CacheJndiName" value="java/CacheManager"/> <property name="ConfigurationFileName" value="<dir>/infinispan-config.xml"/> --> </translator> </vdb>
JCA Resource Adapter
There is no resource adapter for this translator. The cache container is either obtained via JNDI or created (i.e., ConfigurationFileName or RemoteServerList).
You may create a delegating translator by extending the org.teiid.translator.BaseDelegatingExecutionFactory. Once your classes are then packaged as a custom translator, you will be able to wire another translator instance into your delegating translator at runtime in order to intercept all of the calls to the delegate. This base class does not provide any functionality on its own, other than delegation.
Execution Properties
Name | Description | Default |
---|---|---|
delegateName | Translator instance name to delegate to |
Lets say you are currently using "oracle" translator in your VDB, you want to intercept the calls going through this translator, then you first write a custom delegating translator like
@Translator(name="interceptor", description="interceptor") public class InterceptorExecutionFactory extends org.teiid.translator.BaseDelegatingExecutionFactory{ @Override public void getMetadata(MetadataFactory metadataFactory, C conn) throws TranslatorException { // do intercepting code here.. // If you want call the original delegate, do not call if do not need to. // but if you did not call the delegate fullfill the method contract super.getMetadata(metadataFactory, conn); // do more intercepting code here.. } }
Now deploy this translator in Teiid engine. Then in your -vdb.xml or .vdb file define like below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <vdb name="myvdb" version="1"> <model name="mymodel"> <source name="source" translator-name="oracle-interceptor" connection-jndi-name="java:oracle-ds"/> </model> <!-- the below it is called translator overriding, where you can set different properties --> <translator name="orcle-interceptor" type="interceptor" /> <property name="delegateName" value="oracle" /> </translator> </vdb>
We have defined a "translator" override called "oracle-interceptor", which is based on the custom translator "interceptor" from above, and supplied the translator it needs to delegate to "oracle" as its delegateName. Then, we used this override translator "oracle-interceptor" in your VDB. Now any calls going into this VDB model's translator will be intercepted by YOUR code to do whatever you want to do.
select