Convert query argument based on map

Applies to: Denodo 7.0 , Denodo 6.0 , Denodo 5.5 , Denodo 5.0
Last modified on: 28 May 2020
Tags: Combination View creation

Download document

You can translate the document:

Goal

This document describes how to convert a query argument based on a map.

Content

Sometimes, an input parameter needs to be mapped to a different value for use in a query argument.  For instance, a web service that takes a string but then queries a table with an integer.  A real world example is if a web service takes the name of a city as a string but then queries a table with an integer that maps the city.  The reason for this would be that the table was queried with the string argument, then the user has to insert the same exact text as the name of the city in the table being queried.  So instead, each city receives a number.  The string input is mapped to the integer of the matching city.  The table is then queried with that integer.  So,  in the end, it doesn't matter how the city name is inserted because the mapped number, not the inputted string, is used to select the city.

If the mapping is known previously, it can be done by creating a new table or a new csv file that contains the mapped information.  Then, a join view can be created from the table with the mapped information and the originally queried table.  Finally, the join view is queried with the same input parameter as the original query.

Example:

A web service takes the string argument ‘abc’ but then queries a view with integer ‘1’.    Somehow ‘abc’ has to be mapped to ‘1’.

To use the solution suggested above,  first create a delimited file that contains the mapped information, e.g.

STRING        INT

abc                1

bcd                2

cde                3

…                …

Then create a Delimited File data source and base view accessing the new delimited file.  Next, create a Join view from the newly created DF base view and the original queried view.  This Join view will contain all the columns of the originally queried view plus an additional column called STRING.  So now, the join view can be published as a web service and can be queried using a string.  If ‘abc’ is the input then only tuples that have ‘1’ will be returned.

Questions

Ask a question
You must sign in to ask a question. If you do not have an account, you can register here

Featured content

DENODO TRAINING

Ready for more? Great! We offer a comprehensive set of training courses, taught by our technical instructors in small, private groups for getting a full, in-depth guided training in the usage of the Denodo Platform. Check out our training courses.

Training