Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Derive table names from queries used in workflow

Agarwal_Yash91
8 - Asteroid

Hi,

 

we are trying to get the list of various tables used in SQL queries as input for alteryx workflows.

we have derived queries using xml parse and now trying to get list of tables present in input query.

List of Schema names are available in separate sheet.

Example:

Input 1: 

Source SystemSchema Name
PRODSchema_1
PRODSchema_2
PRODSchema_3

 

Input 2:

Tool IDTable query
1select *A. name ,B.id from schema_1.table1 A join schema_1.table2 B on a.no=b.no
2select *A. name ,B.id from schema_2.table1 A1 join schema_2.table2 B1 on a.no=b.no
3select *A. name ,B.id from schema_3.table1 A2 join schema_1.table2 B2 on a.no=b.no
4select *A. name ,B.id from schema_1.table3 A3 join schema_1.table2 B on a.no=b.no

 

Expected Output: 

ToolTables in Use
1schema_1.table1,schema_1.table2
2schema_2.table1 , schema_2.table2
3schema_3.table1 ,schema_1.table2
4 schema_1.table3 ,schema_1.table2

 

Any idea?

 

Thanks

17 REPLIES 17
mceleavey
17 - Castor
17 - Castor

Hi @Agarwal_Yash91 ,

 

I've done this by the cunning use of Regex...

As I can only assume your text string are representative of the real data, I have built the regex to take everything from the word "from" to the first instance of a space and an uppercase letter:

 

(?<=from)(.*)(?=\s\u)

 

This gives the following result:

 

mceleavey_0-1629211960845.png

 

Workflow attached.

Hope this helps,

 

M.



Bulien

atcodedog05
22 - Nova
22 - Nova

Hi @Agarwal_Yash91 

 

Here is my take. I went a step ahead in Regex 😜

 

Workflow:

atcodedog05_0-1629213010362.png

 

Hope this helps : )

 

Agarwal_Yash91
8 - Asteroid

Hi @atcodedog05  is not necessary that Schema name will start or will contain word Schema. schema details are available in different input sheet, i hope it makes some sense.

Agarwal_Yash91
8 - Asteroid

Hi @mceleavey queries can get complicated with lot of sub queries and getting data in this manner will not help.

atcodedog05
22 - Nova
22 - Nova

Hi @Agarwal_Yash91 

 

Here is how you can do it. I am using tokenize to extract schemaname.tablename

Workflow:

atcodedog05_0-1629263977363.png

 

Hope this helps : )

 

Agarwal_Yash91
8 - Asteroid

Hi @atcodedog05 this is not working, getting column names present in select statement 

atcodedog05
22 - Nova
22 - Nova

Hi @Agarwal_Yash91 

 

Please provide more variance of sample data so that we can look into it.

Agarwal_Yash91
8 - Asteroid

Hi @atcodedog05 ,

 

Due to sensitivity of data, I am not able to provide lot of data but somehow managed to mask some of the queries which are not giving desired output.

 

PFA.

atcodedog05
22 - Nova
22 - Nova

Hi @Agarwal_Yash91 

 

Here is how you can do it.

Workflow:

atcodedog05_0-1629267169752.png

 

Hope this helps : )

Labels