How to Query a Data Source Directly

It is possible to query data straight from a Data Source, instead of loading it into a Datamart and querying from there. This can save unnecessary processing of loading from Data Source to Datamart.

Refer to the following API links for more in-depth info:

def dmCtx = api.getDatamartContext() def salesDS = dmCtx.getDataSource("SalesHistory2") def dsQuery = dmCtx.newQuery(salesDS) def filters = [ Filter.equal("Sku", api.product("sku")), ] dsQuery.select("SUM(Revenue)", "revenue") dsQuery.select("SUM(UnitsSold)", "unitsSold") dsQuery.select("YearMonth", "month") dsQuery.where(filters) def result = dmCtx.executeQuery(dsQuery)

Found an issue in documentation? Write to us.

Â