Member since
03-21-2017
5
Posts
0
Kudos Received
0
Solutions
02-02-2018
08:43 AM
Yes. It is possible to retrieve constraints of a Hive table. You need to query the database where Hive stores it's metastore...We are using MySQL database as Hive metastore and below is the query: SELECT d.NAME as SCHEMA_NAME,t.TBL_NAME as TABLE_NAME, kc.CONSTRAINT_NAME, kc.CONSTRAINT_TYPE, c.COLUMN_NAME, c.TYPE_NAME, '' as REFERENCE_SCHEMA_NAME, '' as REFERENCE_TABLE_NAME, '' as REFERENCE_COL_NAME FROM DBS d, TBLS t, SDS s, COLUMNS_V2 c, CDS cds, KEY_CONSTRAINTS kc WHERE d.DB_ID =t.DB_ID AND t.SD_ID = s.SD_ID AND s.cd_id = c.cd_id
AND cds.CD_ID = c.CD_ID AND kc.PARENT_TBL_ID = t.TBL_ID AND kc.PARENT_CD_ID=c.CD_ID AND c.INTEGER_IDX=kc.PARENT_INTEGER_IDX AND CONSTRAINT_TYPE='0'
AND t.tbl_name='pk' AND d.NAME='vsatyp_schema'
UNION ALL SELECT d.NAME as SCHEMA_NAME,t.TBL_NAME as TABLE_NAME, kc.CONSTRAINT_NAME, kc.CONSTRAINT_TYPE, c.COLUMN_NAME, c.TYPE_NAME, p_d.NAME as
REFERENCE_SCHEMA_NAME, p_t.TBL_NAME as REFERENCE_TABLE_NAME, p_c.COLUMN_NAME as REFERENCE_COL_NAME
FROM hive_metastore.DBS d, hive_metastore.TBLS t, hive_metastore.SDS s, hive_metastore.COLUMNS_V2 c, hive_metastore.CDS cds,
hive_metastore.KEY_CONSTRAINTS kc,
hive_metastore.DBS p_d, hive_metastore.TBLS p_t, hive_metastore.SDS p_s, hive_metastore.COLUMNS_V2 p_c, hive_metastore.CDS p_cds WHERE d.DB_ID =t.DB_ID AND t.SD_ID = s.SD_ID AND s.cd_id = c.cd_id AND cds.CD_ID = c.CD_ID AND kc.CHILD_TBL_ID = t.TBL_ID
AND kc.CHILD_CD_ID=c.CD_ID AND c.INTEGER_IDX=kc.CHILD_INTEGER_IDX
AND p_d.DB_ID =p_t.DB_ID AND p_t.SD_ID = p_s.SD_ID AND p_s.cd_id = p_c.cd_id AND p_cds.CD_ID = p_c.CD_ID AND kc.PARENT_TBL_ID = p_t.TBL_ID
AND kc.PARENT_CD_ID=p_c.CD_ID AND p_c.INTEGER_IDX=kc.PARENT_INTEGER_IDX AND CONSTRAINT_TYPE='1'
AND d.NAME in ('vsatyp_schema') and t.tbl_name = 'fk' order by SCHEMA_NAME, TABLE_NAME, CONSTRAINT_TYPE Hope this helps...
... View more
05-22-2017
12:05 PM
Thanks a lot Matt. The last change binlog_format=row was required & missed in my case. Now it is working fine. I could able to see the evets in the flow file. I have one more query, in "column_type" : 4, is value 4 is data type? What are standard data types and are these specific to databases or universally common? Is it linked to java.sql.Types? Let me know.
... View more
05-19-2017
05:04 PM
Thanks Alim for reply... I could see the entries in the bin log file however no events got generated 😞 Request you to share the configuration for MySQL and NiFi CaptureChangeMySQL processor. Also share the output of events by viewing...I think it would be in Jason format. Thanks in advance.
... View more
05-18-2017
02:20 PM
Thanks Matt for quick reply. I have tried INSERT, UPDATE, DELETE events but it didn't worked. You are correct as we don't need auditing I will set it to FALSE but just for testing I enabled it so that at least I got some flow files as output 🙂 Also I tried resetting Retrieve All Records and clearing state but even that won't help. I even downloaded the source code of the CaptureChangeMySQL processor and tried to run the unit test cases but unit test class is in Groovy, I was not able to compile and test it. I am not sure why the unit test class in Groovy when everything else is written in Java language.
... View more
05-18-2017
02:02 PM
I had downloaded the latest version of NiFi 1.2 and tried testing new processor for MySQL CDC CaptureChangeMySQL. All the configuration has been made from mysql side and in NiFi CaptureChangeMySQL processor however I was not able to get the change data as output of SUCCESS. There were no errors or warnings in the log files as well. When I set Include Begin/Commit Events property to TRUE, I got few flow files but that was about events details as {"type":"commit","timestamp":1495114883000,"binlog_filename":"mysql-bin.000001","binlog_position":8155,"database":"test_cdc"} and not the actual changed data. I am not sure what configuration is missing so that CaptureChangeMySQL processor gives me correct output. Let me know if anyone has successfully tested this CaptureChangeMySQL processor in NiFi 1.2. Thanks in advance.
... View more
Labels:
- Labels:
-
Apache NiFi