BUG: ValueError when using hdf select with long select strings
- [x] I have checked that this issue has not already been reported.

- [x] I have confirmed this bug exists on the latest version of pandas.

- [ ] (optional) I have confirmed this bug exists on the master branch of pandas.

---

**Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to provide the necessary information for us to reproduce your bug.

#### Code Sample, a copy-pastable example

```python
import numpy as np
import pandas as pd

# build dataframe and write to hdf file
t = pd.DataFrame([i for i in range(100)], 
             columns=['A'], 
             index=pd.MultiIndex.from_arrays(
                 [[b for a in range(25) for b in ['a', 'b', 'c', 'd']], 
                  range(100)],
                 names=('la','lb')
             )).sort_index()
hdf_test = pd.HDFStore('test.hdf', mode='a', compression=9)
t.to_hdf(hdf_test, 
         '/test', 
         complevel=9,
        format='table'
        )

# build query strings
query1 = []
query2 = []
for idx in t.index:
    query1.append(
        f"(la == '{idx[0]}' & lb == '{idx[1]}')"
    )
    query2.append(
        f"la == {idx[0]}"
    )
 
query1 = ' | '.join(np.unique(query1))
query2 = ' | '.join(np.unique(query2))

# test queries
hdf_test.select('/test', where="(la == 'a' & lb == '0') | (la == 'a' & lb == '12')") # works
hdf_test.select('/test', where=query2) # works
hdf_test.select('/test', where=query1) # fails with  ValueError: too many inputs
```

#### Problem description

The select query fails,  I guess the reason is the long query string.

Note,  in an earlier pandas version (1.2.1) this triggered a `MemoryError` instead of the `ValueError: too many inputs`.

#### Expected Output

dataframe according to query string. (In above case, the full dataframe `t`)

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : 7d32926db8f7541c356066dcadabf854487738de
python           : 3.9.1.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 19.6.0
Version          : Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : en_US.UTF-8
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.2.2
numpy            : 1.20.0
pytz             : 2021.1
dateutil         : 2.8.1
pip              : 21.0.1
setuptools       : 49.6.0.post20210108
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 2.11.3
IPython          : 7.20.0
pandas_datareader: None
bs4              : None
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : 3.3.4
numexpr          : 2.7.2
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pyxlsb           : None
s3fs             : None
scipy            : 1.6.0
sqlalchemy       : None
tables           : 3.6.1
tabulate         : None
xarray           : None
xlrd             : None
xlwt             : None
numba            : None

</details>
