Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Mysql "Select mod(col1, 10) ... " generates bigint. How to make it to be int type

I have following code

String sql = "(select mod_col, 1 as count_col from ( " +
                    "select mod(col1, 10) as mod_col " +
                    "from table1 c " +
                    "where c.col2 = 1) temp " +
                    "group by mod_col, count_col ) as temp2";

DataFrame df = getDSEDataFrame(sql);

Note that the col1 is defined in mysql with type int(11) NOT NULL.

However, when I check the df, the mod_col has the correct value as a bigint. This cause an exception java.math.BigDecimal cannot be cast to java.lang.Integer for my following code

        List<Row> col1List = df.collectAsList();

        for (Row r : col1List) {
             Integer col1Val = r.getAs("mod_col");  // exception thrown here
        }

Is there any way in above sql that I can force it return an integer instead of a big integer?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!