Skip to content
Open
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
7 changes: 7 additions & 0 deletions automation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@
<version>42.7.2</version>
</dependency>

<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.9.8</version>
<classifier>all</classifier>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- start_ignore
-- end_ignore
-- 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.

-- @description ClickHouse JDBC read: expect one row of primitive types from PXF (values compared by regress output)
SET timezone='utc';
SET

SET bytea_output='hex';
SET

SELECT
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
FROM pxf_ch_clickhouse_read_types
LIMIT 1;
i_int | s_small | b_big | f_float32 | d_float64 | b_bool | dec | t_text | bin | d_date | d_ts | d_tstz | d_uuid
-------+---------+-------+-----------+-----------+--------+-------------------+--------+------------+------------+-----------------------+-----------------------+--------------------------------------
1 | 2 | 3 | 1.25 | 3.1415926 | t | 12345.6789012345 | hello | \x41424344 | 2020-01-02 | 2020-01-02 03:04:05.006 | 2020-01-02 03:04:05.006+00 | 550e8400-e29b-41d4-a716-446655440000
(1 row)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- 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.

-- @description ClickHouse JDBC read: expect one row of primitive types from PXF (values compared by regress output)
SET timezone='utc';
SET bytea_output='hex';

SELECT
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
FROM pxf_ch_clickhouse_read_types
LIMIT 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
-- start_ignore
-- end_ignore
-- 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.
-- @description ClickHouse JDBC write: insert full row then verify via readable external table
SET timezone='utc';
SET
SET bytea_output='hex';
SET
INSERT INTO pxf_ch_clickhouse_write_types (
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
) VALUES (
1,
2,
3,
1.25,
3.1415926,
true,
CAST('12345.6789012345' AS numeric),
'hello',
decode('41424344', 'hex'),
DATE '2020-01-02',
TIMESTAMP '2020-01-02 03:04:05.006',
TIMESTAMPTZ '2020-01-02 03:04:05.006+00',
'550e8400-e29b-41d4-a716-446655440000'::uuid
);
INSERT 0 1
SELECT
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
FROM pxf_ch_clickhouse_write_verify
LIMIT 1;
i_int | s_small | b_big | f_float32 | d_float64 | b_bool | dec | t_text | bin | d_date | d_ts | d_tstz | d_uuid
-------+---------+-------+-----------+-----------+--------+-------------------+--------+------------+------------+-----------------------+-----------------------+--------------------------------------
1 | 2 | 3 | 1.25 | 3.1415926 | t | 12345.6789012345 | hello | \x41424344 | 2020-01-02 | 2020-01-02 03:04:05.006 | 2020-01-02 03:04:05.006+00 | 550e8400-e29b-41d4-a716-446655440000
(1 row)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
-- 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.

-- @description ClickHouse JDBC write: insert full row then verify via readable external table
SET timezone='utc';
SET bytea_output='hex';

INSERT INTO pxf_ch_clickhouse_write_types (
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
) VALUES (
1,
2,
3,
1.25,
3.1415926,
true,
CAST('12345.6789012345' AS numeric),
'hello',
decode('41424344', 'hex'),
DATE '2020-01-02',
TIMESTAMP '2020-01-02 03:04:05.006',
TIMESTAMPTZ '2020-01-02 03:04:05.006+00',
'550e8400-e29b-41d4-a716-446655440000'::uuid
);

SELECT
i_int,
s_small,
b_big,
f_float32,
d_float64,
b_bool,
dec,
t_text,
bin,
d_date,
d_ts,
d_tstz,
d_uuid
FROM pxf_ch_clickhouse_write_verify
LIMIT 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.apache.cloudberry.pxf.automation.testcontainers;

/*
* 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.
*/

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
* TestContainers wrapper around ClickHouse server.
*
* The container joins a shared Docker network with alias `clickhouse`,
* so PXF inside the Cloudberry container can reach it at `clickhouse:8123` (HTTP).
*
*/
public class ClickHouseContainer extends GenericContainer<ClickHouseContainer> {

public static final int HTTP_PORT = 8123;

private static final String DEFAULT_IMAGE = "clickhouse/clickhouse-server";
private static final String NETWORK_ALIAS_PREFIX = "clickhouse-";

/**
* Credentials for the test container. ClickHouse 24+ restricts network access for `default`
* until a password is set; `CLICKHOUSE_PASSWORD` configures the server and JDBC must match.
*/
public static final String CLICKHOUSE_USER = "default";
public static final String CLICKHOUSE_PASSWORD = "pxf-test";

private final String networkAlias;

public ClickHouseContainer(String tag, Network network) {
super(DockerImageName.parse(DEFAULT_IMAGE + ":" + tag));

// generate unique DNS name for this Clickhouse container:
this.networkAlias = NETWORK_ALIAS_PREFIX + tag.replaceAll("[-.]", "");

super.withNetwork(network)
.withNetworkAliases(this.networkAlias)
.withExposedPorts(HTTP_PORT)
.withEnv("CLICKHOUSE_USER", CLICKHOUSE_USER)
.withEnv("CLICKHOUSE_PASSWORD", CLICKHOUSE_PASSWORD)
.waitingFor(Wait.forHttp("/ping").forPort(HTTP_PORT));
}

/** Embedded DNS name of this container on the Testcontainers network (for JDBC from other containers). */
public String getNetworkAlias() {
return networkAlias;
}

/** JDBC URL over HTTP, reachable from the host (mapped `HTTP_PORT`). */
public String getJdbcUrl() {
return "jdbc:clickhouse://localhost:" + getMappedPort(HTTP_PORT) + "/default";
}

/** JDBC URL over HTTP for PXF / other containers on the same Docker network. */
public String getInternalJdbcUrl() {
return "jdbc:clickhouse://" + networkAlias + ":" + HTTP_PORT + "/default";
}

public int getHttpMappedPort() {
return getMappedPort(HTTP_PORT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cd /home/gpadmin/workspace/cloudberry-pxf
make -C external-table install
make -C fdw install
make -C server install-server
make -C server install-jdbc-drivers

# Set up PXF environment
export PXF_BASE=$HOME/pxf-base
Expand All @@ -65,6 +66,8 @@ mkdir -p "$PXF_BASE"

# Initialize PXF
pxf prepare
cp $PXF_HOME/lib/*.jar $PXF_BASE/lib/
ls -l $PXF_BASE/lib/
pxf start

# Verify PXF is running
Expand Down
Loading
Loading