Teiid query optimization/ Virtual datasource jasper - jasperserver

I have a query like this:
Select A.table1.atr1, ... , B.table1.atr1
from A.table1
join B.table1 on (A.table1.atr1 = B.table1.atr2)
join B.table2 on (B.table1.atr2 = B.table2.atr2)
...(some similar joins)
join A.table2 on (A.table1.atr1 = A.table2.atr2)
where ...
A and B are jdbc datasources. I wonder how teiid handles multiple joins on the same database. Are they pushed down to the database? Is the join order between table A and B important? In my example i am using a join between A and B, then between B and B and then between A and A. Do i need to rearrange the order or to create 2 temporary tables on database A and database B?

If the database supports joins, yes they can be pushed down. During the planning of the query Teiid optimizer checks the capabilities of source and decides it can be pushed or need to process in Teiid engine. Based on it, it will re-write the query.

Related

Can't we join two tables and fetch data in Kafka?

I have joined two tables and fetched data using Postgres source connector. But every time it gave the same issue i.e.
I have run the same query in Postgres and it runs without any issue. Is fetching data by joining tables not possible in Kafka?
I solve this issue by using the concept of the subquery. The problem was that
when I use an alias, the alias column is interpreted as a whole as a column name and therefore the problem occurs. Here goes my query:
select * from (select p.\"Id\" as \"p_Id\", p.\"CreatedDate\" as p_createddate, p.\"ClassId\" as p_classid, c.\"Id\" as c_id, c.\"CreatedDate\" as c_createddate, c.\"ClassId\" as c_classid from \"PolicyIssuance\" p left join \"ClassDetails\" c on p.\"DocumentNumber\" = c.\"DocumentNo\") as result"

ERPNext: Join multiple tables using script report

Anyone know what is the ORM function for joining multiple db tables in ERPNext?
I need query result from 2 DB tables join using script report
*I don't need query report answer since i already have it. I only looking for an example do it using script report
Frappe currently doesn't have ORM support for joining tables. You might have to use frappe.db.sql for the time being.
data = frappe.db.sql(
"""
select tb1.name from tabTable1 as tb1
left join tabTable2 as tb2 on tb1.name = tb2.employee_name;
"""
);
return data

SQL Tables with no direct relation

I have a PostgreSQL DB and I need to build a query to retrieve the information from a table that has no direct link with the main one.
The client is linked to the client_identity_document through its UUID and client_identity_document to the identity_document through the uuid_identity_document. I know I have to make an inner join, but I just started with relational databases and I don't know exactly the syntax to join tables that don't have direct relation.
try this
select *
from client c
inner join client_identity_document cid on c.UUID = cid.UUID_Client
inner join identity_document id on cid.uuid_identity_document = id.UUID

flink Table SQL Api

I want to know can we write query using two tables ( join) in flink Table and SQL api.
I am new to flik, I want to create two table from two different data set and query them and produce other dataset.
my query would be like select... from table1, table 2... so can we write like this query which querying two tables or more?
Thanks
Flink's Table API supports join operations (full, left, right, inner joins) on batch tables (e.g. those created from a DataSet).
SELECT c, g FROM Table3, Table5 WHERE b = e
For streaming tables (e.g. those created from a DataStream), Flink does not yet support join operations. But the Flink community is actively working to add them in the near future.

SSIS Exporting from one DB to another using parameters in the destination

I have data on table T1 in database DB1.
I need move to the table T2 in database DB2 only those rows of T1 that have Field F1 equals to certain values.
These values are on a table TC in database DB2. DB1 cannot refer to DB2 therefore in the DataFlow Component of my dtsx I cannot write a query with a join between T1 and TC.
I see two possible paths:
I could first import all the rows from T1 then filter them in the dtsx before pouring them in T2
Instead of having a SQL query to get the data from DB1 I could write a stored procedure in DB1 that accepts a table valued parameter and then I could try (I don't know how) to put my parameters (1,2,4 in the example) in the TVP and invoke the stored procedure with this.
I have to do this kind of import for dozens of tables therefore solution 2 seems really too convoluted and complicated. Solution 1 seems to do too much useless work, first importing everything and then discarding part of what was imported.
Is there a best practice or smart trick in this case?
Thank you
You can use a merge join to join data from T1 and Tc on field F1. So two data source, one for T1, one for TC. No parameters are applied yet. You need to use a sort component to sort on the join field (F1) in both result sets for the merge join to work. Then define a join type (inner) in merge join component. This is where the parameters from TC are applied to T1, so you use a inner join to apply the parameters. Finally export the result to T2.
Another way is just import everything from T1 to a temp table on DB2, call it T2_temp, then you can use a query to join T2_temp with TC on F1, then insert the result to T2.