How do you get the query engine to push down a where clause when view has UNION ALL
alan_study May 31, 2019 5:04 PMI have the following view
CREATE VIEW PartMarriage (
src VARCHAR(6), --This is an inline comment in DDL metadata
marriageType VARCHAR(6),
masterSerialNo VARCHAR(20),
masterSerialNoAbbrev VARCHAR(10),
dependentSerialNo VARCHAR(20),
dependentSerialNoAbbrev VARCHAR(10),
CONSTRAINT PK PRIMARY KEY (src, masterSerialNo, masterSerialNoAbbrev, dependentSerialNo, dependentSerialNoAbbrev) --Every view must define a constraint for primary key to be used with odata, MS Access can not have PK with column > 255
)
AS
select
src,
marriageType,
masterSerialNo,
masterSerialNoAbbrev,
dependentSerialNo,
dependentSerialNoAbbrev
from PartMarriageHamDsnVdbHam.PartMarriage
union all
select
src,
marriageType,
masterSerialNo,
masterSerialNoAbbrev,
dependentSerialNo,
dependentSerialNoAbbrev
from PartMarriageDataCollectionVdbAep.PartMarriage
union all
select
src,
marriageType,
masterSerialNo,
masterSerialNoAbbrev,
dependentSerialNo,
dependentSerialNoAbbrev
from PartMarriageGalcHistVdbHma1.PartMarriage
When I use this view like
select
pm1.src pm1_source
, pm1.masterSerialNo pm1_target_sn
, pm1.masterSerialNoAbbrev pm1_target_sn_abbrev
, pm1.dependentSerialNo pm1_sn
, pm1.dependentSerialNoAbbrev pm1_sn_abbrev
from
PartMarriage.PartMarriage pm1
where
pm1.masterSerialNo in
(
'L15BE3105823'
, 'L15BE3105824'
, 'L15BE3105825'
)
and pm1.masterSerialNoAbbrev = 'EIN'
order by
pm1.masterSerialNo
, pm1.dependentSerialNoAbbrev
I was expecting the where clause to get passed down to all of the source models but for some reason it is not. This results in all records being returned.
Here are some logs
2019-05-31 14:57:03.443 DEBUG [org.teiid.COMMAND_LOG] (Worker33988_QueryProcessorQueue6890274) qcd_vdb_ham.33 XrtEXmeRmbma SOURCE SRC COMMAND: endTime=2019-05-31 14:57:03.443 requestID=XrtEXmeRmbma.7 sourceCommandID=10 executionID=686289 txID=null modelName=PartMarriageDataCollectionVdbAep translatorName=teiid sessionID=XrtEXmeRmbma principal=vc039058@AMU sourceCommand=[SELECT g_0."dependentSerialNo" AS c_0, g_0."dependentSerialNoAbbrev" AS c_1, g_0."src" AS c_2, g_0."masterSerialNo" AS c_3, g_0."masterSerialNoAbbrev" AS c_4 FROM "PartMarriage"."PartMarriage" AS g_0 WHERE g_0."masterSerialNo" IN ('L15BE3105823', 'L15BE3105824', 'L15BE3105825') AND g_0."masterSerialNoAbbrev" = 'EIN' ORDER BY c_1, c_4 LIMIT 100]
2019-05-31 14:57:03.469 DEBUG [org.teiid.COMMAND_LOG] (Worker33987_QueryProcessorQueue6890280) qcd_vdb_ham.33 XrtEXmeRmbma START DATA SRC COMMAND: startTime=2019-05-31 14:57:03.469 requestID=XrtEXmeRmbma.7 sourceCommandID=19 executionID=686294 txID=null modelName=PartMarriageHamDsnVdbHam translatorName=teiid sessionID=XrtEXmeRmbma principal=vc039058@AMUsql=SELECT g_0.masterSerialNo, g_0.masterSerialNoAbbrev, g_0.src, g_0.dependentSerialNo, g_0.dependentSerialNoAbbrev FROM PartMarriageHamDsnVdbHam.PartMarriage AS g_0
2019-05-31 14:57:09.852 DEBUG [org.teiid.COMMAND_LOG] (Worker33992_QueryProcessorQueue6891804) qcd_vdb_ham.33 XrtEXmeRmbma END SRC COMMAND: endTime=2019-05-31 14:57:09.852 requestID=XrtEXmeRmbma.7 sourceCommandID=14 executionID=686291 txID=null modelName=PartMarriageHamDsnVdbHam translatorName=teiid sessionID=XrtEXmeRmbma principal=vc039058@AMU finalRowCount=89612 cpuTime(ns)=129362152
Is there anything that I could do to make it pass down the where clause to the select statements that are being unioned together in the view?