Hi all. Is there any way I can `DESCRIBE` a table...
# troubleshooting
v
Hi all. Is there any way I can
DESCRIBE
a table that's already part of a job (not in the execution environment)?
m
I'm not sure I understand. What is it that you're trying to do?
v
I'm using the Table API and SQL. Say if I have a few tables being created:
Copy code
CREATE TABLE a ...
CREATE TABLE b ...
CREATE TABLE c ...
and then I publish a job:
Copy code
EXECUTE STATEMENT SET
BEGIN

INSERT INTO c ...

END
is there any way I can use the
DESCRIBE
statement (https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/describe/) in any of these tables through the job itself?
My use case is that I have an external service that is responsible for converting Flink CREATE TABLE statements to Snowflake CREATE TABLE statements
m
So you basically try to get the output of a DESCRIBE TABLE to influence your logic further downstream?
v
That's right. We're migrating from Flink to Snowflake essentially, and I want to build a script that prepares Snowflake by automatically generating the CREATE TABLE statements, converts datatypes, etc.
m
While never tried it, I would expect that you should be able to do something like
Copy code
Table resultTable =
                tableEnv.sqlQuery(
                        String.join(
                                "\n",
                                "SELECT t_id, c_name, CAST(t_amount AS DECIMAL(5, 2))",
                                "FROM Customers",
                                "JOIN (SELECT DISTINCT * FROM Transactions) ON c_id = t_customer_id"));
But then with a DESCRIBE statement. Not 100% sure though