Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Merge develop to master for ODFE 1.9.0.1 release #633

Merged
merged 36 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b071f51
Merge all SQL repos and adjust workflows (#549)
joshuali925 Jul 9, 2020
0622896
adding filter for columns in SQLColumns call (#556)
rupal-bq Jul 10, 2020
4b139c4
Keep mismatch results when error occurs in comparison test (#557)
dai-chen Jul 10, 2020
13afbe5
Support mathematical functions ceil/ceiling, exp, floor, ln, log (#540)
chloe-zh Jul 12, 2020
bc02233
add date and time support (#568)
penghuo Jul 13, 2020
eea2920
ODBC: Build driver files in parallel (#570)
jordanw-bq Jul 13, 2020
4888d37
ODBC: Remove catalog support from driver (#566)
jordanw-bq Jul 13, 2020
7fbe349
ODBC: Add documents for `Refresh` & `Export as CSV files` options in …
rupal-bq Jul 13, 2020
51f353d
ODBC: Update documentation for using Microsoft Excel with Open Distro…
rupal-bq Jul 14, 2020
0b57d93
Add workflow to draft release on push (#572)
joshuali925 Jul 16, 2020
9d72867
Support mathematical functions: conv, crc32, mod, pow/power, round, s…
chloe-zh Jul 20, 2020
d74cb81
Fix object/nested field select issue (#584)
dai-chen Jul 20, 2020
c66b85f
ODBC: Add user documentation for using Microsoft Excel on Mac (#594)
rupal-bq Jul 20, 2020
af4ff91
ODBC: add ODBC 2.x functions called by Excel for Mac (#592)
jordanw-bq Jul 20, 2020
8262994
ODBC: Updating Microsoft Excel connection documents (#581)
rupal-bq Jul 20, 2020
c9ea038
Extra fixes for Mac ODBC driver (#602)
jordanw-bq Jul 21, 2020
277c966
bumped lodash version (#598)
chloe-zh Jul 21, 2020
0a878ab
Support SELECT * and FROM clause in new SQL parser (#573)
dai-chen Jul 21, 2020
5365ca0
ODBC: Adding Power BI M connector (#596)
rupal-bq Jul 21, 2020
e8f0539
Using UTC as default timezone for date_format function if not provide…
penghuo Jul 21, 2020
7372a44
Fix CAST bool field to integer issue (#600)
dai-chen Jul 22, 2020
78a51a4
Support mathematical functions rand and constants e, pi (#591)
chloe-zh Jul 22, 2020
49883b9
Support trigonometric functions acos, asin, atan, atan2, cos, cot, de…
chloe-zh Jul 22, 2020
353c1c8
Add ElasticsearchExprValueFactory in StorageEngine (#608)
penghuo Jul 23, 2020
6ba778f
Update docs after merging repos (#563)
joshuali925 Jul 24, 2020
3368d60
ODBC: Report error from Excel when executing an invalid query (#611)
jordanw-bq Jul 25, 2020
f3517ee
ODBC: adding manual test plan for Microsoft Excel testing (#604)
rupal-bq Jul 25, 2020
9dac0ac
ODBC: Adding BASIC & AWS_SIGV4 auth in M Connector (#610)
rupal-bq Jul 25, 2020
e370ce9
ODBC: Change Tableau connector version (#622)
rupal-bq Jul 28, 2020
5a7084f
Issue 623, fix security vulnerability regarding to depedencies common…
penghuo Jul 28, 2020
0211d7e
Support queries end with semi colon (#609)
dai-chen Jul 29, 2020
bee2ca2
ODBC: Fix for data loading failure in Power BI Desktop (#627)
rupal-bq Jul 29, 2020
b258fda
Add Text and Keyword Data Type (#620)
penghuo Jul 29, 2020
e61b5fd
Move workbench down in kibana nav (#578)
joshuali925 Jul 29, 2020
caf21a6
Bump versions to 1.9.0.1 and add release notes (#632)
joshuali925 Jul 29, 2020
baac103
resolve conflict
joshuali925 Jul 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support trigonometric functions acos, asin, atan, atan2, cos, cot, de…
…grees, radians, sin, tan (#599)

* support trigonometric functions acos, asin, atan, atan2, cos, cot, degrees, radians, sin, tan

* updated doc

* added sql comparison test cases

* added integ test cases in ppl

* update
  • Loading branch information
chloe-zh authored Jul 22, 2020
commit 49883b9b1a66eae3d40cf56b53f70a619b5f34d8
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public static LiteralExpression literal(ExprValue value) {
return new LiteralExpression(value);
}

/**
* Wrap a number to {@link LiteralExpression}.
*/
public static LiteralExpression literal(Number value) {
if (value instanceof Integer) {
return new LiteralExpression(ExprValueUtils.integerValue(value.intValue()));
} else if (value instanceof Long) {
return new LiteralExpression(ExprValueUtils.longValue(value.longValue()));
} else if (value instanceof Float) {
return new LiteralExpression(ExprValueUtils.floatValue(value.floatValue()));
} else {
return new LiteralExpression(ExprValueUtils.doubleValue(value.doubleValue()));
}
}

public static ReferenceExpression ref(String ref, ExprType type) {
return new ReferenceExpression(ref, type);
}
Expand Down Expand Up @@ -144,6 +159,46 @@ public FunctionExpression truncate(Expression... expressions) {
return function(BuiltinFunctionName.TRUNCATE, expressions);
}

public FunctionExpression acos(Expression... expressions) {
return function(BuiltinFunctionName.ACOS, expressions);
}

public FunctionExpression asin(Expression... expressions) {
return function(BuiltinFunctionName.ASIN, expressions);
}

public FunctionExpression atan(Expression... expressions) {
return function(BuiltinFunctionName.ATAN, expressions);
}

public FunctionExpression atan2(Expression... expressions) {
return function(BuiltinFunctionName.ATAN2, expressions);
}

public FunctionExpression cos(Expression... expressions) {
return function(BuiltinFunctionName.COS, expressions);
}

public FunctionExpression cot(Expression... expressions) {
return function(BuiltinFunctionName.COT, expressions);
}

public FunctionExpression degrees(Expression... expressions) {
return function(BuiltinFunctionName.DEGREES, expressions);
}

public FunctionExpression radians(Expression... expressions) {
return function(BuiltinFunctionName.RADIANS, expressions);
}

public FunctionExpression sin(Expression... expressions) {
return function(BuiltinFunctionName.SIN, expressions);
}

public FunctionExpression tan(Expression... expressions) {
return function(BuiltinFunctionName.TAN, expressions);
}

public FunctionExpression add(Expression... expressions) {
return function(BuiltinFunctionName.ADD, expressions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public enum BuiltinFunctionName {
SQRT(FunctionName.of("sqrt")),
TRUNCATE(FunctionName.of("truncate")),

ACOS(FunctionName.of("acos")),
ASIN(FunctionName.of("asin")),
ATAN(FunctionName.of("atan")),
ATAN2(FunctionName.of("atan2")),
COS(FunctionName.of("cos")),
COT(FunctionName.of("cot")),
DEGREES(FunctionName.of("degrees")),
RADIANS(FunctionName.of("radians")),
SIN(FunctionName.of("sin")),
TAN(FunctionName.of("tan")),

/**
* Text Functions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public static void register(BuiltinFunctionRepository repository) {
repository.register(truncate());
repository.register(pi());
repository.register(rand());
repository.register(acos());
repository.register(asin());
repository.register(atan());
repository.register(atan2());
repository.register(cos());
repository.register(cot());
repository.register(degrees());
repository.register(radians());
repository.register(sin());
repository.register(tan());
}

/**
Expand Down Expand Up @@ -487,6 +497,154 @@ private static FunctionResolver truncate() {
.build());
}

/**
* Definition of acos(x) function.
* Calculates the arc cosine of x, that is, the value whose cosine is x.
* Returns NULL if x is not in the range -1 to 1.
* The supported signature of acos function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver acos() {
FunctionName functionName = BuiltinFunctionName.ACOS.getName();
return new FunctionResolver(
functionName,
singleArgumentFunction(functionName, v -> v < -1 || v > 1 ? null : Math.acos(v)));
}

/**
* Definition of asin(x) function.
* Calculates the arc sine of x, that is, the value whose sine is x.
* Returns NULL if x is not in the range -1 to 1.
* The supported signature of asin function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver asin() {
FunctionName functionName = BuiltinFunctionName.ASIN.getName();
return new FunctionResolver(
functionName,
singleArgumentFunction(functionName, v -> v < -1 || v > 1 ? null : Math.asin(v)));
}

/**
* Definition of atan(x) and atan(y, x) function.
* atan(x) calculates the arc tangent of x, that is, the value whose tangent is x.
* atan(y, x) calculates the arc tangent of y / x, except that the signs of both arguments
* are used to determine the quadrant of the result.
* The supported signature of atan function is
* (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE
*/
private static FunctionResolver atan() {
FunctionName functionName = BuiltinFunctionName.ATAN.getName();
return new FunctionResolver(functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Arrays.asList(ExprCoreType.DOUBLE)),
unaryOperator(
functionName, Math::atan, ExprValueUtils::getDoubleValue, ExprCoreType.DOUBLE))
.put(
new FunctionSignature(
functionName, Arrays.asList(ExprCoreType.DOUBLE, ExprCoreType.DOUBLE)),
doubleArgFunc(functionName,
Math::atan2, ExprValueUtils::getDoubleValue, ExprValueUtils::getDoubleValue,
ExprCoreType.DOUBLE))
.build());
}

/**
* Definition of atan2(y, x) function.
* Calculates the arc tangent of y / x, except that the signs of both arguments
* are used to determine the quadrant of the result.
* The supported signature of atan2 function is
* (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE
*/
private static FunctionResolver atan2() {
FunctionName functionName = BuiltinFunctionName.ATAN2.getName();
return new FunctionResolver(functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(
functionName, Arrays.asList(ExprCoreType.DOUBLE, ExprCoreType.DOUBLE)),
doubleArgFunc(functionName,
Math::atan2, ExprValueUtils::getDoubleValue, ExprValueUtils::getDoubleValue,
ExprCoreType.DOUBLE))
.build());
}

/**
* Definition of cos(x) function.
* Calculates the cosine of X, where X is given in radians
* The supported signature of cos function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver cos() {
FunctionName functionName = BuiltinFunctionName.COS.getName();
return new FunctionResolver(functionName, singleArgumentFunction(functionName, Math::cos));
}

/**
* Definition of cot(x) function.
* Calculates the cotangent of x
* The supported signature of cot function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver cot() {
FunctionName functionName = BuiltinFunctionName.COT.getName();
return new FunctionResolver(
functionName,
singleArgumentFunction(functionName, v -> {
if (v == 0) {
throw new ArithmeticException(String.format("Out of range value for cot(%s)", v));
}
return 1 / Math.tan(v);
}));
}

/**
* Definition of degrees(x) function.
* Converts x from radians to degrees
* The supported signature of degrees function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver degrees() {
FunctionName functionName = BuiltinFunctionName.DEGREES.getName();
return new FunctionResolver(
functionName, singleArgumentFunction(functionName, Math::toDegrees));
}

/**
* Definition of radians(x) function.
* Converts x from degrees to radians
* The supported signature of radians function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver radians() {
FunctionName functionName = BuiltinFunctionName.RADIANS.getName();
return new FunctionResolver(
functionName, singleArgumentFunction(functionName, Math::toRadians));
}

/**
* Definition of sin(x) function.
* Calculates the sine of x, where x is given in radians
* The supported signature of sin function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver sin() {
FunctionName functionName = BuiltinFunctionName.SIN.getName();
return new FunctionResolver(functionName, singleArgumentFunction(functionName, Math::sin));
}

/**
* Definition of tan(x) function.
* Calculates the tangent of x, where x is given in radians
* The supported signature of tan function is
* INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
*/
private static FunctionResolver tan() {
FunctionName functionName = BuiltinFunctionName.TAN.getName();
return new FunctionResolver(functionName, singleArgumentFunction(functionName, Math::tan));
}

/**
* Util method to generate single argument function bundles. Applicable for INTEGER -> INTEGER
* LONG -> LONG FLOAT -> FLOAT DOUBLE -> DOUBLE
Expand Down
Loading