Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6813823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:36:54+00:00 2026-05-26T20:36:54+00:00

I am using HIVE with two tables looking like (more or less): -TABLE1 defined

  • 0

I am using HIVE with two tables looking like (more or less):

-TABLE1 defined as [(Variables : string),(Value1 : int),(Value2 : int)]

with field “Variables” looking like “x0,x1,x2,x3,…,xn”

-TABLE2 define as [(Value1Sum : int),(Value2Sum : int),(X1 : string),(X4 : string),(X17 : string)]

I “convert” table1 to table2 with the query :

INSERT OVERWRITE TABLE table2
    SELECT sum(v1), sum(v2), x1, x4, x17
        FROM (SELECT
                Value1 as v1,
                Value2 as v2,
                split(Variables, ",")[1] as x1,
                split(Variables, ",")[4] as x4,
                split(Variables, ",")[17] as x17 
              FROM Table1) tmp
        GROUP BY tmp.x1, tmp.x4, tmp.x17

Does Hive call 3 times the split function ?

Is there a way to make it more elegant ?

Is there a way to make it more generic ?

Best regards,
CC

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:36:54+00:00Added an answer on May 26, 2026 at 8:36 pm

    Yes it will call split each time. You can make it slightly more elegant:

    Why not define Variables as an array column to start with? They you can access elements directly:

    select Varaibles[1] from table1
    

    I’m assuming you’re using an external table, so you can do that like so:

    create external table table1(variables array<string>, a int, b int)
    ROW FORMAT DELIMITED
        COLLECTION ITEMS TERMINATED BY ','
    LOCATION 'hdfs://somewhere'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to connect to a Hadoop-based Hive datastore using Perl. Hive allows connection
I'm running a Hadoop job using Hive actually that is supposed to uniq lines
I created a hive table as in Create external with Partition I am using
I am running hive query using get_json_object to read json strings from files in
I'm trying to replace registry hive file by using RegReplaceKey() (new file is created
I would like to know how to run Pig queries stored in Hive format.
I have matched the 12 hive structure in my solution, and I am using
I am about to embark on a project using Apache Hadoop/Hive which will involve
I would like to execute a Hive query on the server in an asynchronous
I need to execute queries on HBase using hive. I have downloaded the HBase

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.