Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/static/generated/rest_v1_sql_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ components:
- DESCRIPTOR
- VARIANT
- BITMAP
- GEOGRAPHY
OpenSessionRequestBody:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/static/generated/rest_v2_sql_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ components:
- DESCRIPTOR
- VARIANT
- BITMAP
- GEOGRAPHY
OpenSessionRequestBody:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/static/generated/rest_v3_sql_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ components:
- DESCRIPTOR
- VARIANT
- BITMAP
- GEOGRAPHY
OpenSessionRequestBody:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/static/generated/rest_v4_sql_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ components:
- DESCRIPTOR
- VARIANT
- BITMAP
- GEOGRAPHY
OpenSessionRequestBody:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.flink.table.types.logical;

import org.apache.flink.annotation.PublicEvolving;

import java.util.Collections;
import java.util.List;

/**
* Data type of geography data.
*
* <p>The serializable string representation of this type is {@code GEOGRAPHY}.
*/
@PublicEvolving
public final class GeographyType extends LogicalType {

private static final long serialVersionUID = 1L;

private static final String FORMAT = "GEOGRAPHY";

private static final Class<?> INPUT_OUTPUT_CONVERSION = Object.class;

public GeographyType(boolean isNullable) {
super(isNullable, LogicalTypeRoot.GEOGRAPHY);
}

public GeographyType() {
this(true);
}

@Override
public LogicalType copy(boolean isNullable) {
return new GeographyType(isNullable);
}

@Override
public String asSerializableString() {
return withNullability(FORMAT);
}

@Override
public boolean supportsInputConversion(Class<?> clazz) {
return INPUT_OUTPUT_CONVERSION == clazz;
}

@Override
public boolean supportsOutputConversion(Class<?> clazz) {
return INPUT_OUTPUT_CONVERSION == clazz;
}

@Override
public Class<?> getDefaultConversion() {
return INPUT_OUTPUT_CONVERSION;
}

@Override
public List<LogicalType> getChildren() {
return Collections.emptyList();
}

@Override
public <R> R accept(LogicalTypeVisitor<R> visitor) {
return visitor.visit(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ public enum LogicalTypeRoot {

VARIANT(LogicalTypeFamily.EXTENSION),

BITMAP(LogicalTypeFamily.EXTENSION);
BITMAP(LogicalTypeFamily.EXTENSION),

GEOGRAPHY(LogicalTypeFamily.EXTENSION);

private final Set<LogicalTypeFamily> families;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@ default R visit(BitmapType bitmapType) {
return visit((LogicalType) bitmapType);
}

default R visit(GeographyType geographyType) {
return visit((LogicalType) geographyType);
}

R visit(LogicalType other);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.flink.table.types.logical.DistinctType;
import org.apache.flink.table.types.logical.DoubleType;
import org.apache.flink.table.types.logical.FloatType;
import org.apache.flink.table.types.logical.GeographyType;
import org.apache.flink.table.types.logical.IntType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
import org.apache.flink.table.types.logical.LogicalType;
Expand Down Expand Up @@ -203,6 +204,11 @@ public R visit(BitmapType bitmapType) {
return defaultMethod(bitmapType);
}

@Override
public R visit(GeographyType geographyType) {
return defaultMethod(geographyType);
}

@Override
public R visit(LogicalType other) {
return defaultMethod(other);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.flink.table.types.logical.DescriptorType;
import org.apache.flink.table.types.logical.DoubleType;
import org.apache.flink.table.types.logical.FloatType;
import org.apache.flink.table.types.logical.GeographyType;
import org.apache.flink.table.types.logical.IntType;
import org.apache.flink.table.types.logical.LegacyTypeInformationType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
Expand Down Expand Up @@ -336,7 +337,8 @@ private enum Keyword {
DESCRIPTOR,
STRUCTURED,
VARIANT,
BITMAP
BITMAP,
GEOGRAPHY
}

private static final Set<String> KEYWORDS =
Expand Down Expand Up @@ -586,6 +588,8 @@ private LogicalType parseTypeByKeyword() {
return new VariantType();
case BITMAP:
return new BitmapType();
case GEOGRAPHY:
return new GeographyType();
default:
throw parsingError("Unsupported type: " + token().value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.flink.table.types.logical.DescriptorType;
import org.apache.flink.table.types.logical.DoubleType;
import org.apache.flink.table.types.logical.FloatType;
import org.apache.flink.table.types.logical.GeographyType;
import org.apache.flink.table.types.logical.IntType;
import org.apache.flink.table.types.logical.LegacyTypeInformationType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
Expand Down Expand Up @@ -309,6 +310,8 @@ private static Stream<TestSpec> testData() {
TestSpec.forString("VARIANT NOT NULL").expectType(new VariantType(false)),
TestSpec.forString("BITMAP").expectType(new BitmapType()),
TestSpec.forString("BITMAP NOT NULL").expectType(new BitmapType(false)),
TestSpec.forString("GEOGRAPHY").expectType(new GeographyType()),
TestSpec.forString("GEOGRAPHY NOT NULL").expectType(new GeographyType(false)),

// error message testing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.flink.table.types.logical.DistinctType;
import org.apache.flink.table.types.logical.DoubleType;
import org.apache.flink.table.types.logical.FloatType;
import org.apache.flink.table.types.logical.GeographyType;
import org.apache.flink.table.types.logical.IntType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
import org.apache.flink.table.types.logical.LogicalType;
Expand Down Expand Up @@ -629,6 +630,20 @@ void testBitmapType() {
new BitmapType(false)));
}

@Test
void testGeographyType() {
assertThat(new GeographyType())
.isJavaSerializable()
.satisfies(
baseAssertions(
"GEOGRAPHY",
"GEOGRAPHY",
new Class[] {Object.class},
new Class[] {Object.class},
new LogicalType[] {},
new GeographyType(false)));
}

@Test
void testTypeInformationRawType() {
final TypeInformationRawType<?> rawType =
Expand Down