Skip to content

Instantly share code, notes, and snippets.

@mwiewior
Last active April 4, 2017 12:32
Show Gist options
  • Save mwiewior/d65ff6ad0499590acfae7eb7bfb90bbe to your computer and use it in GitHub Desktop.
Save mwiewior/d65ff6ad0499590acfae7eb7bfb90bbe to your computer and use it in GitHub Desktop.
scala> carbon.sql("""select * from dwh_dev2.fact_orc where f_variant_name='chr1:896764_G/C' and f_sample_id=41447""").show
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+
|f_sample_id|f_geo_id|f_d_id|f_ensembl_gp_id|f_refseq_gp_id|   f_v_id| f_variant_name|f_chr| f_pos|f_ref|f_alt|f_alter_depth|f_total_depth|f_genotype|
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+
|      41447|     384|     0|            213|          null|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|           null|        317151|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|           null|         64563|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|         324486|          null|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+

scala> carbon.sql("""CREATE TABLE dwh_dev2.fact_carbon_test(
     |   `f_sample_id` bigint,
     |   `f_geo_id` bigint,
     |   `f_d_id` bigint,
     |   `f_ensembl_gp_id` bigint,
     |   `f_refseq_gp_id` bigint,
     |   `f_v_id` bigint,
     |   `f_variant_name` string,
     |   `f_chr` string,
     |   `f_pos` bigint,
     |   `f_ref` string,
     |   `f_alt` string,
     |   `f_alter_depth` int,
     |   `f_total_depth` int,
     |   `f_genotype` string) stored by 'carbondata'
     | """)

scala> carbon.sql("""insert into dwh_dev2.fact_carbon_test select * from dwh_dev2.fact_orc where f_variant_name='chr1:896764_G/C' and f_sample_id=41447""").show


scala> carbon.sql("""select * from dwh_dev2.fact_carbon_test""").show
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+
|f_sample_id|f_geo_id|f_d_id|f_ensembl_gp_id|f_refseq_gp_id|   f_v_id| f_variant_name|f_chr| f_pos|f_ref|f_alt|f_alter_depth|f_total_depth|f_genotype|
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+
|      41447|     384|     0|            213|          null|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|           null|        317151|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|           null|         64563|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
|      41447|     384|     0|         324486|          null|377052304|chr1:896764_G/C| chr1|896764|    G|    C|           13|           24|       0/1|
+-----------+--------+------+---------------+--------------+---------+---------------+-----+------+-----+-----+-------------+-------------+----------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment