Uploaded image for project: 'CarbonData'
  1. CarbonData
  2. CARBONDATA-1956

Select query with sum, count and avg throws exception for pre aggregate table

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.0
    • 1.3.0
    • data-query
    • None
    • spark2.1

    Description

      I create a datamap using the following command:

      create datamap uniqdata_agg_d on table uniqdata_29 using 'preaggregate' as select sum(decimal_column1), count(cust_id), avg(bigint_column1) from uniqdata_29 group by cust_id;

      The datamap creation was successfull, but when I tried the following query:
      select sum(decimal_column1), count(cust_id), avg(bigint_column1) from uniqdata_29 group by cust_id;

      It throws the following exception:
      Error: org.apache.spark.sql.AnalysisException: cannot resolve '(sum(uniqdata_29_uniqdata_agg_d.`uniqdata_29_bigint_column1_sum`) / sum(uniqdata_29_uniqdata_agg_d.`uniqdata_29_bigint_column1_count`))' due to data type mismatch: '(sum(uniqdata_29_uniqdata_agg_d.`uniqdata_29_bigint_column1_sum`) / sum(uniqdata_29_uniqdata_agg_d.`uniqdata_29_bigint_column1_count`))' requires (double or decimal) type, not bigint;;
      'Aggregate uniqdata_29_cust_id_count#244, sum(uniqdata_29_decimal_column1_sum#243) AS sum(decimal_column1)#274, sum(cast(uniqdata_29_cust_id_count#244 as bigint)) AS count(cust_id)#276L, (sum(uniqdata_29_bigint_column1_sum#245L) / sum(uniqdata_29_bigint_column1_count#246L)) AS avg(bigint_column1)#279
      +- Relationuniqdata_29_decimal_column1_sum#243,uniqdata_29_cust_id_count#244,uniqdata_29_bigint_column1_sum#245L,uniqdata_29_bigint_column1_count#246L CarbonDatasourceHadoopRelation [ Database name :28dec, Table name :uniqdata_29_uniqdata_agg_d, Schema :Some(StructType(StructField(uniqdata_29_decimal_column1_sum,DecimalType(30,10),true), StructField(uniqdata_29_cust_id_count,IntegerType,true), StructField(uniqdata_29_bigint_column1_sum,LongType,true), StructField(uniqdata_29_bigint_column1_count,LongType,true))) ] (state=,code=0)

      Steps for creation of maintable:
      CREATE TABLE uniqdata_29(CUST_ID int,CUST_NAME String,ACTIVE_EMUI_VERSION string, DOB timestamp, DOJ timestamp, BIGINT_COLUMN1 bigint,BIGINT_COLUMN2 bigint,DECIMAL_COLUMN1 decimal(30,10), DECIMAL_COLUMN2 decimal(36,10),Double_COLUMN1 double, Double_COLUMN2 double,INTEGER_COLUMN1 int) STORED BY 'org.apache.carbondata.format';

      Load command:
      LOAD DATA INPATH 'hdfs://localhost:54311/Files/2000_UniqData.csv' into table uniqdata_29 OPTIONS('DELIMITER'=',', 'QUOTECHAR'='"','BAD_RECORDS_ACTION'='FORCE','FILEHEADER'='CUST_ID,CUST_NAME,ACTIVE_EMUI_VERSION,DOB,DOJ,BIGINT_COLUMN1,BIGINT_COLUMN2,DECIMAL_COLUMN1,DECIMAL_COLUMN2,Double_COLUMN1,Double_COLUMN2,INTEGER_COLUMN1');

      Datamap creation command:
      create datamap uniqdata_agg_d on table uniqdata_29 using 'preaggregate' as select sum(decimal_column1), count(cust_id), avg(bigint_column1) from uniqdata_29 group by cust_id;

      Note: select sum(decimal_column1), count(cust_id), avg(bigint_column1) from uniqdata_29 group by cust_id; executed successfully on maintable

      Attachments

        1. 2000_UniqData.csv
          367 kB
          Geetika Gupta

        Activity

          People

            Unassigned Unassigned
            geetikagupta Geetika Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: