hasColumns
The hasColumns method is used to check whether a table contains a column (or columns) with the provided column name(s).
Syntax
source.hasColumns(columnNames...)
source.hasColumns(columnNames)
Parameters
| Parameter | Type | Description |
|---|---|---|
| columnNames | String... | The column name(s). |
| columnNames | Collection<String> | The column name(s). |
Returns
A boolean value that is true if all columns are in the table, or false if any of the provided column names are not found in the table.
Example
The following example checks for the existence of certain column names in a table with three columns.
source = newTable(
stringCol("Title", "content"),
stringCol("ColumnName", "column_content"),
stringCol("AnotherColumn", "string"),
)
println source.hasColumns("Title")
println source.hasColumns("NotAColumnName")
println source.hasColumns("Title", "ColumnName")
println source.hasColumns("Title", "NotAName")