Skip to content

Commit

Permalink
Added SHOW TABLES and DESCRIBE table support
Browse files Browse the repository at this point in the history
  • Loading branch information
aadilkhalifa committed Jul 10, 2024
1 parent e80d95f commit e1131e7
Show file tree
Hide file tree
Showing 9 changed files with 1,139 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,48 @@ public static Object arrayValueConstructor(Object... arr) {
}
return arr;
}

@ScalarFunction
public static int[] generateIntArray(int start, int end, int inc) {
int size = (end - start) / inc + 1;
int[] arr = new int[size];

for (int i = 0, value = start; i < size; i++, value += inc) {
arr[i] = value;
}
return arr;
}

@ScalarFunction
public static long[] generateLongArray(long start, long end, long inc) {
int size = (int) ((end - start) / inc + 1);
long[] arr = new long[size];

for (int i = 0; i < size; i++, start += inc) {
arr[i] = start;
}
return arr;
}

@ScalarFunction
public static float[] generateFloatArray(float start, float end, float inc) {
int size = (int) ((end - start) / inc + 1);
float[] arr = new float[size];

for (int i = 0; i < size; i++, start += inc) {
arr[i] = start;
}
return arr;
}

@ScalarFunction
public static double[] generateDoubleArray(double start, double end, double inc) {
int size = (int) ((end - start) / inc + 1);
double[] arr = new double[size];

for (int i = 0; i < size; i++, start += inc) {
arr[i] = start;
}
return arr;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pinot.sql.parsers.parser;

import java.util.List;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.SqlSpecialOperator;
import org.apache.calcite.sql.SqlWriter;
import org.apache.calcite.sql.parser.SqlParserPos;

public class SqlShowTables extends SqlCall {

private static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("UDF", SqlKind.OTHER);

protected SqlShowTables(SqlParserPos pos) {
super(pos);
}

@Override public SqlOperator getOperator() {
return OPERATOR;
}

@Override
public List<SqlNode> getOperandList() {
return List.of();
}

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
UnparseUtils u = new UnparseUtils(writer, leftPrec, rightPrec);
u.keyword("SHOW", "TABLES");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class FunctionDefinitionRegistryTest {
private static final List<String> IGNORED_FUNCTION_NAMES = ImmutableList.of(
// Geo functions are defined in pinot-core
"geotoh3",
// ArrayToMV and ArrayValueConstructor are placeholder functions without implementation
"arraytomv", "arrayvalueconstructor",
// ArrayToMV, ArrayValueConstructor and GenerateArray are placeholder functions without implementation
"arraytomv", "arrayvalueconstructor", "generatearray",
// Scalar function
"scalar",
// Functions without scalar function counterpart as of now
Expand Down
Loading

0 comments on commit e1131e7

Please sign in to comment.