Skip to content

Commit

Permalink
Merge pull request #17056 from [BEAM-14076] [SnowflakeIO] Add support…
Browse files Browse the repository at this point in the history
… for GEOGRAPHY column

* [BEAM-14076] [SnowflakeIO] Add support for GEOGRAPHY column in SnowflakeIO

* fixup! [BEAM-14076] [SnowflakeIO] Add support for GEOGRAPHY column in SnowflakeIO

* fixup! fixup! [BEAM-14076] [SnowflakeIO] Add support for GEOGRAPHY column in SnowflakeIO
  • Loading branch information
sfc-gh-kbregula authored Mar 11, 2022
1 parent 03af085 commit 9e0aa6b
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.beam.sdk.io.snowflake.data.datetime.SnowflakeTimestampLTZ;
import org.apache.beam.sdk.io.snowflake.data.datetime.SnowflakeTimestampNTZ;
import org.apache.beam.sdk.io.snowflake.data.datetime.SnowflakeTimestampTZ;
import org.apache.beam.sdk.io.snowflake.data.geospatial.SnowflakeGeography;
import org.apache.beam.sdk.io.snowflake.data.logical.SnowflakeBoolean;
import org.apache.beam.sdk.io.snowflake.data.numeric.SnowflakeDecimal;
import org.apache.beam.sdk.io.snowflake.data.numeric.SnowflakeDouble;
Expand Down Expand Up @@ -73,6 +74,7 @@
@Type(value = SnowflakeText.class, name = "text"),
@Type(value = SnowflakeVarBinary.class, name = "varbinary"),
@Type(value = SnowflakeVarchar.class, name = "varchar"),
@Type(value = SnowflakeGeography.class, name = "geography"),
})
public interface SnowflakeDataType extends Serializable {
String sql();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.beam.sdk.io.snowflake.data.geospatial;

import org.apache.beam.sdk.io.snowflake.data.SnowflakeDataType;

public class SnowflakeGeography implements SnowflakeDataType {
public SnowflakeGeography() {}

public static SnowflakeGeography of() {
return new SnowflakeGeography();
}

@Override
public String sql() {
return "GEOGRAPHY";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

/** Snowflake IO geospatial types. */
package org.apache.beam.sdk.io.snowflake.data.geospatial;
73 changes: 40 additions & 33 deletions sdks/python/apache_beam/io/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,41 +353,48 @@ def user_data_mapper(user):
CREATE_IF_NEEDED, the table_schema parameter enables specifying the
schema for the created target table. A table schema is as JSON with the
following structure:
{"schema":[
{
"dataType":{"type":"<COLUMN DATA TYPE>"},
"name":"<COLUMN NAME> ",
"nullable": <NULLABLE>
},
]}
.. code-block:: none
{"schema":[
{
"dataType":{"type":"<COLUMN DATA TYPE>"},
"name":"<COLUMN NAME>",
"nullable": <NULLABLE>
},
]}
All supported data types:
{"schema":[
{"dataType":{"type":"date"},"name":"","nullable":false},
{"dataType":{"type":"datetime"},"name":"","nullable":false},
{"dataType":{"type":"time"},"name":"","nullable":false},
{"dataType":{"type":"timestamp"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_ltz"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_ntz"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_tz"},"name":"","nullable":false},
{"dataType":{"type":"boolean"},"name":"","nullable":false},
{"dataType":{"type":"decimal","precision":38,"scale":1},"name":"","nullable":true},
{"dataType":{"type":"double"},"name":"","nullable":false},
{"dataType":{"type":"float"},"name":"","nullable":false},
{"dataType":{"type":"integer","precision":38,"scale":0},"name":"","nullable":false},
{"dataType":{"type":"number","precision":38,"scale":1},"name":"","nullable":false},
{"dataType":{"type":"numeric","precision":38,"scale":2},"name":"","nullable":false},
{"dataType":{"type":"real"},"name":"","nullable":false},
{"dataType":{"type":"array"},"name":"","nullable":false},
{"dataType":{"type":"object"},"name":"","nullable":false},
{"dataType":{"type":"variant"},"name":"","nullable":true},
{"dataType":{"type":"binary","size":null},"name":"","nullable":false},
{"dataType":{"type":"char","length":1},"name":"","nullable":false},
{"dataType":{"type":"string","length":null},"name":"","nullable":false},
{"dataType":{"type":"text","length":null},"name":"","nullable":false},
{"dataType":{"type":"varbinary","size":null},"name":"","nullable":false},
{"dataType":{"type":"varchar","length":100},"name":"","nullable":false}]
}
.. code-block:: json
{"schema":[
{"dataType":{"type":"date"},"name":"","nullable":false},
{"dataType":{"type":"datetime"},"name":"","nullable":false},
{"dataType":{"type":"time"},"name":"","nullable":false},
{"dataType":{"type":"timestamp"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_ltz"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_ntz"},"name":"","nullable":false},
{"dataType":{"type":"timestamp_tz"},"name":"","nullable":false},
{"dataType":{"type":"boolean"},"name":"","nullable":false},
{"dataType":{"type":"decimal","precision":38,"scale":1},"name":"","nullable":true},
{"dataType":{"type":"double"},"name":"","nullable":false},
{"dataType":{"type":"float"},"name":"","nullable":false},
{"dataType":{"type":"integer","precision":38,"scale":0},"name":"","nullable":false},
{"dataType":{"type":"number","precision":38,"scale":1},"name":"","nullable":false},
{"dataType":{"type":"numeric","precision":38,"scale":2},"name":"","nullable":false},
{"dataType":{"type":"real"},"name":"","nullable":false},
{"dataType":{"type":"array"},"name":"","nullable":false},
{"dataType":{"type":"object"},"name":"","nullable":false},
{"dataType":{"type":"variant"},"name":"","nullable":true},
{"dataType":{"type":"binary","size":null},"name":"","nullable":false},
{"dataType":{"type":"char","length":1},"name":"","nullable":false},
{"dataType":{"type":"string","length":null},"name":"","nullable":false},
{"dataType":{"type":"text","length":null},"name":"","nullable":false},
{"dataType":{"type":"varbinary","size":null},"name":"","nullable":false},
{"dataType":{"type":"varchar","length":100},"name":"","nullable":false},
{"dataType":{"type":"geography"},"name":"","nullable":true}]
}
"""
verify_credentials(
username=username,
Expand Down

0 comments on commit 9e0aa6b

Please sign in to comment.