# Can I validate a list of predefined columns and ignore the rest?

**URL:** <https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563>\
**Category:** Archive\
**Created:** [December 15, 2020, 5:46pm UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563 "2020-12-15T17:46:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhcastleton](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/bhcastleton/32/73_2.png) [@bhcastleton](https://discourse.greatexpectations.io/u/bhcastleton)\
**Post date:** [December 15, 2020, 5:46pm UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563/1 "2020-12-15T17:46:10Z")

</div>

For example, if I have 5 columns [a, b, c, d, e] that are always the same on a dataset but sometimes I also have additional columns so that my column list could look like this [a, b, c, d, e, x, y, z] or it could look like this [a, b, c, d, e, t, s, r], is there a way to validate that the first 5 columns are always there without worrying about the additional columns?

---

<div class="post-metadata">

**Author:** ![bhcastleton](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/bhcastleton/32/73_2.png) [@bhcastleton](https://discourse.greatexpectations.io/u/bhcastleton)\
**Post date:** [December 15, 2020, 5:53pm UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563/2 "2020-12-15T17:53:22Z")

</div>

As of v 0.13.2, we don’t have functionality in `expect_table_columns_to_match_ordered_list` that would allow you to ignore columns after the ordered list. So the workaround would be to create an expect\_column\_to\_exist expectation for each predefined column, setting the column\_index number to expect each column in the respective column position needed. This will check that the first 5 columns are there as expected and will ignore the rest. This workaround won’t be ideal for huge tables with hundreds of columns. A contribution would be welcome to add a configuration option to the expect\_table\_columns\_to\_match\_ordered\_list expectation so that it can ignore additional columns.

---

<div class="post-metadata">

**Author:** ![anthony](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/anthony/32/68_2.png) [@anthony](https://discourse.greatexpectations.io/u/anthony)\
**Post date:** [December 15, 2020, 11:24pm UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563/3 "2020-12-15T23:24:06Z")

</div>

@bhcastleton - it’s not exactly the same, but you could use `expect_table_columns_to_match_set(column_set=[a, b, c, d, e], exact_match=False)` to make sure that the columns [a, b, c, d, e] exist. By setting exact\_match=False, this expectation will still return success=True if there are extra columns in the dataset that are not in the column\_set.

The difference between this and what you are describing is that this method does not check order of these columns.

---

<div class="post-metadata">

**Author:** ![bhcastleton](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/bhcastleton/32/73_2.png) [@bhcastleton](https://discourse.greatexpectations.io/u/bhcastleton)\
**Post date:** [December 17, 2020, 7:24am UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563/4 "2020-12-17T07:24:50Z")

</div>

Nice @anthony! Yes, that solution might work better in cases where there are lots of columns. Great idea.

---

<div class="post-metadata">

**Author:** ![cogsp](https://avatars.discourse-cdn.com/v4/letter/c/3ab097/32.png) [@cogsp](https://discourse.greatexpectations.io/u/cogsp)\
**Post date:** [December 20, 2020, 8:18pm UTC](https://discourse.greatexpectations.io/t/can-i-validate-a-list-of-predefined-columns-and-ignore-the-rest/563/5 "2020-12-20T20:18:03Z")

</div>

Thanks for the suggestions. I played around a bit and submitted a pr: [https://github.com/great-expectations/great\_expectations/pull/2200](https://github.com/great-expectations/great_expectations/pull/2200)

Mostly did this as an exercise to see if I can get to grips with parts of the codebase, so I won’t be offended if it needs work 🙂
