From a844cde41027a742274921d946d2207360a5c804 Mon Sep 17 00:00:00 2001 From: Alessandro Solimando Date: Sat, 27 Apr 2024 21:57:14 +0200 Subject: [PATCH] [CALCITE-6388] PsTableFunction throws NumberFormatException when the 'user' column has spaces --- .../org/apache/calcite/adapter/os/PsTableFunction.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java b/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java index 8c829877b2be..58181e87ba12 100644 --- a/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java +++ b/plus/src/main/java/org/apache/calcite/adapter/os/PsTableFunction.java @@ -61,20 +61,20 @@ public static ScannableTable eval(boolean b) { case "Mac OS X": // tested on version 10.12.5 args = new String[] { "ps", "ax", "-o", "ppid=,pid=,pgid=,tpgid=,stat=," - + "user=,pcpu=,pmem=,vsz=,rss=,tty=,start=,time=,uid=,ruid=," - + "sess=,comm="}; + + "pcpu=,pmem=,vsz=,rss=,tty=,start=,time=,uid=,ruid=," + + "sess=,comm=,user="}; break; default: args = new String[] { "ps", "--no-headers", "axo", "ppid,pid,pgrp," - + "tpgid,stat,user,pcpu,pmem,vsz,rss,tty,start_time,time,euid," - + "ruid,sess,comm"}; + + "tpgid,stat,pcpu,pmem,vsz,rss,tty,start_time,time,euid," + + "ruid,sess,comm,user"}; } return Processes.processLines(args) .select( new Function1() { @Override public Object[] apply(String line) { - final String[] fields = line.trim().split(" +"); + final String[] fields = line.trim().split(" +", fieldNames.size()); final Object[] values = new Object[fieldNames.size()]; for (int i = 0; i < values.length; i++) { try {