Replace table::as_table_state with table::try_get_table_state_with_static_sharding which throws if a table does not use static sharding.
Replace table::as_table_state with table::try_get_table_state_with_static_sharding which throws if a table does not use static sharding.