Denodo Json Source and Base View: how to make VQL more traditional SQL syntax - denodo

I have a web service api
In Denodo, I have virtualized the following api:
https://delphi.cmu.edu/epidata/fluview/?regions=nat&epiweeks=201501,201601,201701
as
https://delphi.cmu.edu/epidata/fluview/?regions=#{regions}&epiweeks=#{epiweeks}
This allows us, in Denodo, to write the following:
Select * from bv_fluview where epiweeks = '201501,201601,201701' and regions = 'nat'
Is there any way where the query could be written in a more traditional way such as:
Select * from bv_fluview where epiweeks in ('201501','201601','201701') and regions = 'nat'
I am relatively new to Denodo.
Thanks,
Dan

In Denodo, you can use the IN clause to check if a value is present in a list
SELECT *
FROM bv_fluview
WHERE epiweeks IN ('201501','201601','201701')
AND regions = 'nat'
This would return the same result as your original query but with a more conventional syntax for the IN operator.

Related

Different text used of sorting and filtering

in a app, I use jQueryTablesorter, and the widget https://mottie.github.io/tablesorter/docs/example-widget-filter.html
I have two main features :
- filtering (the widget)
- sorting (default feature)
Both of these feature use textExtraction() function,
https://mottie.github.io/tablesorter/docs/#textextraction
My problem is the following :
for sorting, I would like to use computer form of a date, that is "2020-04-01"
for filtering, I would like to use human form (in French "1er avril 2020").
How can I deal with it ?
You might need to use a date library like sugar or date.js - check out this demo: https://mottie.github.io/tablesorter/docs/example-parsers-dates.html. What that library does is use the parser to convert the filter into a normalized date that will match with the date in the column. You would also need to add a filter-parsed class name to the column (ref).
I have found. I need to use a hook which modify the value parsed for filtering.
$.tablesorter.filter.types.start = function(config, data) {
data.exact = data.$cells[data.index];
data.exact = data.exact.innerText;
data.iExact = data.exact.toLowerCase();
return null;
}

How to exclude multiple values in OData call?

I am creating a SAPUI5 application. This application is connected to a backend SAP system via OData. In the SAPUI5 application I use a smart chart control. Out of the box the smart chart lets the user create filters for the underlying data. This works fine - except if you try to use multiple 'not equals' for one property. Is there a way to accomplish this?
I found out that all properties within an 'and_expression' (including nested or_expressions) must have unique name.
The reason why two parameters with the same property don't get parsed into the select options:
/IWCOR/CL_ODATA_EXPR_UTILS=>GET_FILTER_SELECT_OPTIONS takes the expression you pass and parses it into a table of select options.
The select option table returned is of type /IWCOR/IF_ODATA_TYPES=>EDM_SELECT_OPTION_T which is a HASHED TABLE .. WITH UNIQUE KEY property.
From: https://archive.sap.com/discussions/thread/3170195
The problem is that you cannot combine NE terms with OR. Because both parameters after the NE should not be shown in the result set.
So at the end the it_filter_select_options is empty and only the iv_filter_string is filled.
Is there a manual way of facing this problem (evaluation of the iv_filter_string) to handle multiple NE terms?
This would be an example request:
XYZ/SmartChartSet?$filter=(Category%20ne%20%27Smartphone%27%20and%20Category%20ne%20%27Notebook%27)%20and%20Purchaser%20eq%20%27CompanyABC%27%20and%20BuyDate%20eq%20datetime%272018-10-12T02%3a00%3a00%27&$inlinecount=allpages
Normally I want this to exclude items with the category 'Notebook' and 'Smartphone' from my result set that I retrieve from the backend.
If there is a bug inside /iwcor/cl_odata_expr_utils=>get_filter_select_options which makes it unable to treat multiple NE filters of the same component, and you cannot wait for an OSS. I would suggest to wrap it inside a new static method that will make the following logic (if you will be stuck with the ABAP implementation i would try to at least partially implement it when i get time):
Get all instances of <COMPONENT> ne '<VALUE>' inside a () (using REGEX).
Replace each <COMPONENT> with <COMPONENT>_<i> so there will be ( <COMPONENT>_1 ne '<VALUE_1>' and <COMPONENT>_2 ne '<VALUE_2>' and... <COMPONENT>_<n> ne '<VALUE_n>' ).
Call /iwcor/cl_odata_expr_utils=>get_filter_select_options with the modified query.
Modify the rt_select_options result by changing COMPONENT_<i> to <COMPONENT> again.
I can't find the source but I recall that multiple "ne" isn't supported. Isn't that the same thing that happens when you do multiple negatives in SE16, some warning is displayed?
I found this extract for Business ByDesign:
Excluding two values using the OR operator (for example: $filter=CACCDOCTYPE ne ‘1000’ or CACCDOCTYPE ne ‘4000’) is not possible.
The workaround I see is to select the Categories you actively want, not the ones you don't in the UI5 app.
I can also confirm that my code snippet I've used a long time for filtering also has the same problem...
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_MGW_ABS_DATA->FILTERING
* +-------------------------------------------------------------------------------------------------+
* | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITYSET
* | [<-->] CR_ENTITYSET TYPE REF TO DATA
* | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
* | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD FILTERING.
FIELD-SYMBOLS <lt_entityset> TYPE STANDARD TABLE.
ASSIGN cr_entityset->* TO <lt_entityset>.
CHECK: cr_entityset IS BOUND,
<lt_entityset> IS ASSIGNED.
DATA(lo_filter) = io_tech_request_context->get_filter( ).
/iwbep/cl_mgw_data_util=>filtering(
exporting it_select_options = lo_filter->get_filter_select_options( )
changing ct_data = <lt_entityset> ).
ENDMETHOD.

Correct way to update map data type with cqerl

I am having hard time coming with the syntax of updating map using cqerl. I have tried the following till now and it doesn't work
statement = "UPDATE keyspace SET data[?] = :data_value WHERE scope = ?;",
values = [{data,"Key Value"},{data_value, "Data Value",{scope, "Scope Value"}]
What am I doing wrong here?
Also setting ttl does not work
statement = "INSERT INTO data(scope)
VALUES(?) USING ttl ?",
values = [{scope, "Scope Value"},{[ttl], 3650}]
Anyone, any idea?
Please note that you are using single quotes around the values, which in Erlang syntax indicates you are using atoms. Based on the documentation cqerl, it doesn't expect atoms there. cqerl data types
For example try:
statement = "INSERT INTO data(scope)
VALUES(?) USING ttl ?",
values = [{scope, "Scope Value"},{[ttl], 3650}]
Based on reply from the contributor on github, it takes an atom, so '[ttl]' is the right way
https://github.com/matehat/cqerl/issues/122
For updating a map correct way is with atom in the values part
statement = "UPDATE keyspace SET data[?] = ? WHERE scope = ?;",
values = [{'key(data)',"Key Value"},{'value(data)', "Data Value",{scope, "Scope Value"}]

Groovy name queried

I got a domain like this:
ZZPartAndTeam
String parts
String team
Parts may have many team.
For ex: part:part1 team:10
part:part1 team:20
part:part2 team:30
How can I query in the domain that get all parts which have multi team?
result:part:part1 team:10
part:part1 team:20
Thanks.
The HAVING clause is not supported by Hibernate Criteria. A way around is to use DetachedCriteria.
import org.hibernate.criterion.DetachedCriteria as HDetachedCriteria
query: { builder, params ->
// This query counts the number of teams per part
HDetachedCriteria innerQry = HDetachedCriteria.forClass(ZZPartAndTeam.class)
innerQry.setProjection(Projections.projectionList()
.add(Projections.count('team').as('teamCount'))
)
innerQry.add(HRestrictions.eqProperty('part', 'outer.part')
// Using innerQuery, this criteria returns the parts having more than one team.
HDetachedCriteria outerQry = HDetachedCriteria.forClass(ZZPartAndTeam.class, 'outer')
outerQry.setProjection(Projections.projectionList()
.add(Projections.distinct(Projections.property('part').as('part')))
)
outerQry.add(Subqueries.gt(1, innerQry))
builder.addToCriteria(Property.forName('part').in(outerQry))
}

How to use Slickgrid Formatters with MVC

I am working on a first Slickgrid MVC application where the column definition and format is to be stored in a database. I can retrieve the list of columns quite happily and populate them until I ran into the issue with formatting of dates. No problem - for each date (or time) column I can store a formatter name in the database so this can be retrieved as well. I'm using the following code which works ok:
CLOP_ViewColumnsDataContext columnDB = new CLOP_ViewColumnsDataContext();
var results = from u in columnDB.CLOP_VIEW_COLUMNs
select u;
List<dynColumns> newColumns = new List<dynColumns>();
foreach(CLOP_VIEW_COLUMN column in results)
{
newColumns.Add(new dynColumns
{
id = column.COLUMN_NUMBER.ToString(),
name = column.HEADING.Trim(),
field = column.VIEW_FIELD.Trim(),
width = column.WIDTH,
formatter = column.FORMATTER.Trim()
});
}
var gridColumns = new JavaScriptSerializer().Serialize(newColumns);
This is all fine apart from the fomatter. An example of the variable gridColumns is:
[{"id":"1","name":"Date","field":"SCHEDULED_DATE","width":100,"formatter":"Slick.Formatters.Date"},{"id":"2","name":"Carrier","field":"CARRIER","width":50,"formatter":null}]
Which doesn't look too bad however the application the fails with the error Microsoft JScript runtime error: Function expected in the slick.grid.js script
Any help much appreciated - even if there is a better way of doing this!
You are assigning a string to the formatter property, wich is expected to be function.
Try:
window["Slick"]["Formatters"]["Date"];
But i really think you should reconsider doing it this way and instead store your values in the db and define your columns through code.
It will be easier to maintain and is less error prone.
What if you decide to use custom editors and formatters, which you later rename?
Then your code will break or you'll have to rename all entries in the db as well as in code.

Resources