Skip to content

Commit

Permalink
[KYUUBI apache#1839] Improve docs and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
link3280 committed Jan 27, 2022
1 parent a187a53 commit b870427
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,31 @@ object ResultSetUtil {

/**
* Build a ResultSet with a column name and a list of String values.
*
* @param strings list of String values
* @param columnName name of the result column
* @return a ResultSet with a string column
*/
def stringListToResultSet(strings: List[String], columnName: String): ResultSet = {
val rows: Array[Row] = strings.map(s => Row.of(s)).toArray
ResultSet.builder.resultKind(ResultKind.SUCCESS_WITH_CONTENT).columns(Column.physical(
columnName,
DataTypes.STRING)).data(rows).build
ResultSet.builder
.resultKind(ResultKind.SUCCESS_WITH_CONTENT)
.columns(Column.physical(columnName, DataTypes.STRING))
.data(rows)
.build
}

/**
* Build a simple ResultSet with OK message. Returned when SQL commands are executed successfully.
* Noted that a new ResultSet is returned each time, because ResultSet is stateful (with its
* cursor).
*
* @return A simple ResultSet with OK message.
* @return a simple ResultSet with OK message.
*/
def successResultSet: ResultSet =
ResultSet.builder.resultKind(ResultKind.SUCCESS_WITH_CONTENT).columns(Column.physical(
"result",
DataTypes.STRING)).data(Array[Row](Row.of("OK"))).build
ResultSet.builder
.resultKind(ResultKind.SUCCESS_WITH_CONTENT)
.columns(Column.physical("result", DataTypes.STRING))
.data(Array[Row](Row.of("OK")))
.build
}

0 comments on commit b870427

Please sign in to comment.