Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-7647

Beeline does not honor --headerInterval and --color when executing with "-e"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.14.0
    • 0.14.0
    • CLI
    • Beeline does not honor --headerInterval and --color options when running with "-e" option. It results in header being printed after each row. This has now been resolved in Hive 0.14.

    Description

      --showHeader is being honored
      [root@localhost ~]# beeline --showHeader=false -u 'jdbc:hive2://localhost:10000/default' -n hive -d org.apache.hive.jdbc.HiveDriver -e "select * from sample_07 limit 10;"
      Connecting to jdbc:hive2://localhost:10000/default
      Connected to: Apache Hive (version 0.12.0-cdh5.0.1)
      Driver: Hive JDBC (version 0.12.0-cdh5.0.1)
      Transaction isolation: TRANSACTION_REPEATABLE_READ
      -hiveconf (No such file or directory)

      ---------------------------------------------------------------+

      00-0000 All Occupations 135185230 42270
      11-0000 Management occupations 6152650 100310
      11-1011 Chief executives 301930 160440
      11-1021 General and operations managers 1697690 107970
      11-1031 Legislators 64650 37980
      11-2011 Advertising and promotions managers 36100 94720
      11-2021 Marketing managers 166790 118160
      11-2022 Sales managers 333910 110390
      11-2031 Public relations managers 51730 101220
      11-3011 Administrative services managers 246930 79500

      ---------------------------------------------------------------+
      10 rows selected (0.838 seconds)
      Beeline version 0.12.0-cdh5.1.0 by Apache Hive
      Closing: org.apache.hive.jdbc.HiveConnection

      --outputFormat is being honored.
      [root@localhost ~]# beeline --outputFormat=csv -u 'jdbc:hive2://localhost:10000/default' -n hive -d org.apache.hive.jdbc.HiveDriver -e "select * from sample_07 limit 10;"
      Connecting to jdbc:hive2://localhost:10000/default
      Connected to: Apache Hive (version 0.12.0-cdh5.0.1)
      Driver: Hive JDBC (version 0.12.0-cdh5.0.1)
      Transaction isolation: TRANSACTION_REPEATABLE_READ

      'code','description','total_emp','salary'
      '00-0000','All Occupations','135185230','42270'
      '11-0000','Management occupations','6152650','100310'
      '11-1011','Chief executives','301930','160440'
      '11-1021','General and operations managers','1697690','107970'
      '11-1031','Legislators','64650','37980'
      '11-2011','Advertising and promotions managers','36100','94720'
      '11-2021','Marketing managers','166790','118160'
      '11-2022','Sales managers','333910','110390'
      '11-2031','Public relations managers','51730','101220'
      '11-3011','Administrative services managers','246930','79500'
      10 rows selected (0.664 seconds)
      Beeline version 0.12.0-cdh5.1.0 by Apache Hive
      Closing: org.apache.hive.jdbc.HiveConnection

      both --color & --headerInterval are being honored when executing using "-f" option (reads query from a file rather than the commandline) (cannot really see the color here but use the terminal colors)

      [root@localhost ~]# beeline --showheader=true --color=true --headerInterval=5 -u 'jdbc:hive2://localhost:10000/default' -n hive -d org.apache.hive.jdbc.HiveDriver -f /tmp/tmp.sql
      Connecting to jdbc:hive2://localhost:10000/default
      Connected to: Apache Hive (version 0.12.0-cdh5.0.1)
      Driver: Hive JDBC (version 0.12.0-cdh5.0.1)
      Transaction isolation: TRANSACTION_REPEATABLE_READ

      Beeline version 0.12.0-cdh5.1.0 by Apache Hive
      0: jdbc:hive2://localhost> select * from sample_07 limit 8;
      ---------------------------------------------------------------+

      code description total_emp salary

      ---------------------------------------------------------------+

      00-0000 All Occupations 135185230 42270
      11-0000 Management occupations 6152650 100310
      11-1011 Chief executives 301930 160440
      11-1021 General and operations managers 1697690 107970
      11-1031 Legislators 64650 37980

      ---------------------------------------------------------------+

      code description total_emp salary

      ---------------------------------------------------------------+

      11-2011 Advertising and promotions managers 36100 94720
      11-2021 Marketing managers 166790 118160
      11-2022 Sales managers 333910 110390

      ---------------------------------------------------------------+
      8 rows selected (0.921 seconds)
      0: jdbc:hive2://localhost> Closing: org.apache.hive.jdbc.HiveConnection

      But when running
      beeline --showheader=true --color=true --headerInterval=5 -u 'jdbc:hive2://localhost:10000/default' -n hive -d org.apache.hive.jdbc.HiveDriver -e "select * from sample_07 limit 8;"

      headerInterval & color are being overridden in the code.
      From Beeline.java
      if (commands.size() > 0) {
      // for single command execute, disable colorgetOpts().setColor(false);
      getOpts().setHeaderInterval(-1);

      This overrides the default behavior. The documentation states that the default headerInterval is 100 for "table" output format. By default "table" output format is used with "-e" option but that headerInterval is being set to "-1" which results in header being printed after every row (since HIVE-7200).

      Attachments

        1. HIVE-7647.1.patch
          0.7 kB
          Naveen Gangam
        2. HIVE-7647.2.patch
          0.7 kB
          Naveen Gangam

        Activity

          People

            ngangam Naveen Gangam
            ngangam Naveen Gangam
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: