Goal
This document is a quick reference for migrating DB2 SQL to Denodo VQL. The document is aimed at administrators and developers that want to efficiently migrate their existing DB2 queries to Denodo VQL queries.
Content
The Knowledge Base article VDP Conformance with Standard SQL contains a reference of the Virtual DataPort conformance with the SQL 92 standard. The document is focused on query capabilities and contains information about: Data Types, SQL Predicates Support and SQL Functions Support. The Query Expressions section lists the expressions defined by the standard SQL and their equivalent in Virtual DataPort, explaining the differences with the standard when appropriate.
Following, a group of tables where the correspondence between DB2 functions and the Denodo equivalents is presented. This list is just a reference since more functions can be included in future Denodo versions.
Functions mapping
Denodo function |
DB2 function |
cast(data_type, value) |
cast(value as data_type) |
coalesce(arg0 [, argi]*) |
|
concat(arg0, arg1, arg2) |
concat(arg0,concat(arg1, arg2)) |
textcat(arg0, arg1, arg2) |
concat(arg0,concat(arg1, arg2)) |
formatdate(date_pattern, datetimevalue [, localename]) |
VARCHAR_FORMAT(date,date_pattern[, localename) to_char(date,date_pattern[, localename) |
getday(daterelatedvalue) |
DAY(date) |
gethour(timerelatedvalue) |
hour(date) |
getminute(timerelatedvalue) |
minute(date) |
getsecond(timerelatedvalue) |
second(date) |
gettimeinmillis(daterelatedvalue) |
TIMESTAMPDIFF(2,CHAR(t0.DATEOFBIRTH - TIMESTAMP('1970-01-01-00.00.00.000000'))) |
getmonth(daterelatedvalue) |
month(date) |
getyear(daterelatedvalue) |
year(date) |
getmillisecond(daterelatedvalue) |
trunc(microsecond(date)/1000, 0) |
getdaysbetween(daterelatedvalue1, daterelatedvalue2) |
days(date2) - days(date1) |
getmonthsbetween(daterelatedvalue1, daterelatedvalue2) |
int(months_between(date2, date1)) |
getdayofweek(daterelatedvalue) |
dayofweek(date) |
getdayofyear(daterelatedvalue) |
dayofyear(date) |
instr(arg0, arg1) |
(POSSTR(arg0,arg0) -1) |
degrees(arg0) |
degrees(arg0) |
radians(arg0) |
radians(arg0) |
log(arg0) |
log10(arg0) |
ltrim(arg0) |
ltrim(arg0) |
now() |
to_date() |
max(arg0 [,argi]*) |
max(arg0 [,argi]*) |
min(arg0 [,argi]*) |
min(arg0 [,argi]*) |
removeaccents(arg0) |
replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(arg0, 'Ý', 'Y'), 'Û', 'U'), 'Ô', 'O'), 'Î', 'I'), 'Ê', 'E'), ' ', 'A'), 'Ü', 'U'), 'Ö', 'O'), 'Ï', 'I'), 'Ë', 'E'), 'Ä', 'A'), 'Ù', 'U'), 'Ò', 'O'), 'Ì', 'I'), 'È', 'E'), 'À', 'A'), 'Ú', 'U'), 'Ó', 'O'), 'Í', 'I'), 'É', 'E'), 'Á', 'A'), 'ý', 'y'), 'ÿ', 'y'), 'û', 'u'), 'ô', 'o'), 'î', 'i'), 'ê', 'e'), 'â', 'a'), 'ü', 'u'), 'ö', 'o'), 'ï', 'i'), 'ë', 'e'), 'ä', 'a'), 'ù', 'u'), 'ò', 'o'), 'ì', 'i'), 'è', 'e'), 'à', 'a'), 'ú', 'u'), 'ó', 'o'), 'í', 'i'), 'é', 'e'), 'á', 'a') |
repeat(arg0, count) |
repeat(arg0, count) |
round(arg0 [, arg1]) |
round(arg0 [, arg1]) |
rtrim(arg0) |
rtrim(arg0) |
substr(arg0, arg1) |
SUBSTR(arg0,arg1) |
substr(arg0, arg1,arg2) |
SUBSTR(arg0,arg1,arg2) |
to_date(date_pattern, value) |
to_date(value, date_pattern) |
addday(daterelatedvalue,inc) |
DATE + inc DAY |
addhour(timerelatedvalue,inc) |
DATE + inc HOUR |
addminute(timerelatedvalue,inc) |
DATE +inc MINUTE |
addsecond(timerelatedvalue,inc) |
DATE + inc SECOND |
addmonth(daterelatedvalue,inc) |
|
addweek(daterelatedvalue,inc) |
DATE +(inc*7) DAY |
addyear(daterelatedvalue,inc) |
DATE + inc YEAR |
firstdayofmonth(daterelatedvalue) |
add_months(last_day(date),-1)+1 |
firstdayofweek(daterelatedvalue) |
NEXT_DAY(date-7,<first weekday abbreviation depending on locale, example 'SUN' for sunday>) |
lastdayofmonth(daterelatedvalue) |
last_day(date) |
lastdayofweek(daterelatedvalue) |
next_day(date-1, <first weekday abbreviation depending on locale, example 'SAT' for saturday>) |
nextweekday(daterelatedvalue,weekDay) |
next_day(date,weekDay) |
previousweekday(daterelatedvalue,weekDay) |
next_day(date-8,weekDay) |
trunc(daterelatedvalue[,pattern]) |
trunc(date[,pattern]) |
current_date |
date(to_date()) |
len(arg0) |
LENGTH(arg0) |
CASE WHEN arg0 THEN arg1 [WHEN argi THEN argj] [ELSE argk] |
CASE WHEN arg0 THEN arg1 [WHEN argi THEN argj] [ELSE argk] |
ceil(arg0) |
ceiling(arg0) |
In the above list, there are different types of data and time functions:
- Functions that are related with datetime types that includes dates (date, localdate, timestamp, timestamptz), will be referred as daterelatedvalue.
- Functions that are related with datetime types that includes times (date, time, timestamp, timestamptz), will be referred as timerelatedvalue.
- Functions that receive any datetime values, except intervals, will be referred as datetimevalue.
Aggregation functions
Denodo Function |
DB2 function |
stdevp(arg0) |
STDDEV(arg0) |
varp(arg0) |
VARIANCE(arg0) |
count(arg0) |
count_big(arg0) |
The information provided in the Denodo Knowledge Base is intended to assist our users in advanced uses of Denodo. Please note that the results from the application of processes and configurations detailed in these documents may vary depending on your specific environment. Use them at your own discretion.
For an official guide of supported features, please refer to the User Manuals. For questions on critical systems or complex environments we recommend you to contact your Denodo Customer Success Manager.