The punctuation of words makes sense.
To understand the answer, one need to know the rules of definite article in hebrew. In hebrew it is a letter "hey" adjointed at the begining of a word. In hebrew, there is an other case in which a letter "hey" is adjointed at the begining of a word, a hey that express a question, or demonstrate astonishment. It's generally called "Hey of questioning", one can see in the link that the rules of the "hey of questioning" and "hey of knowledge" are different. Following both rules, it's obvious that the verse doesn't ask if human spirit ascend or not. The sentence of Kohelet es however a question, but a question is "who knows", because to understand the nature of human spirit needs a great wisdom. The question is rethoric, as to say, nobody understands.
I quoted below a sample of Jewish authorized commentator who are as major grammarians, regarding our verse.
הָעולה היא למעלה. has a kamats on the letter Hei, there is not a
question about the ascent of human soul. See the machberet of Menachem who report that this verse is surprising (¹), and see Ibn Ezra(²) on the verse. An interrogative formation should be with a patach.
As @Heshy pointed, Ibn Ezra addresses also the Hey of היורדת is with a full patach and the yud after this Hey is with dagesh, sign that this is not an interrogation.
So, with a grammatically correct lecture, there is no discrepancy between King Salomon and rabanim. The issue is there are few people who understand the essential difference between mankind and animals.
(¹): on word Adam
יש על אנשי לבב להשתומם על אמרת שלמה המשכיל ולתמוה ממליצתו כי אמנם יש פליאה בפתרוני מליו. הלא הוא אומר והרוח תשוב אל האלהים אשר נתנה (קהלת יב, יז). ועתה אומר מי יודע אם עולה אם יורדת אך ממוצא דבר הבין כי הרוח תשוב אל מכונה והאדם ישוב אל יסודו. ומה יוכל המשכיל להשיג בשכלו דבר רוח האדם ורוח הבהמה אם עולה אם יורדת. יש על אנשי לבב לאחז באורח השכל... ... אלו היתה תמיהא היתה ההא פתוחה...
(²):
" מי יודע" - ידוע כי ה"א הידיעה אם בא אחריו אחד מא"ח הע"ר הוא קמוץ ברוב ושל התימה לעולם בפתח וה"א העולה היא למעלה קמץ גם יש דגוש ביו"ד שאחרי ה"א הידיע' כמו היושב' ואילו היה לתימ' היה שוא ופתח תחת הה"א והיו"ד רפה והענין מי ומי שידע בבני האדם ההפרש שיש בין רוח האדם ורוח הבהמה והענין כי לא ימצא אחד מני אלף ודעת הרוח עמוקה וצריכה לראיו' ולא יוכלו להבין אפילו קצתם כי אם המשכילים שהתבררה מחשבתם במאזני החכמה ..... ... עוד יש עזר בנקודת המלה ויורה עליה וירחיקנה מתמיהא כי
אמנם אלו היתה תמיהא היתה היתה פתוחה
An interpretation of the verses from 18 to 22 following Ibn Ezra:
The verses speak ironically.
(18) I said in my heart concerning the sons of men, that God is testing them, that they might see that they are but beasts.
(19) For that which befalls the sons of men befalls beasts; one thing befalls them both; as the one dies, so dies the other; They have all one breath; so that a man has no preeminence above a beast; for all is vanity.
Ibn Ezra זה הפסוק על מחשבות בני אדם שלא חכמו והשכילו כי בראות' שמקרה אחד לאדם ולבהמה בחיים ובמות חשבו כי רוח אחד לכל ואין לאדם מותר מן הבהמ' ומותר שם על משקל מושב מן הבנין הכבד והנח הוא תמור' פ' הפועל שהוא יו"ד ויתרון שם מן הבנין הקל והנו"ן נוסף
This verse talk about views of poeple who have not though enough. They reach conclusion, after finding that one thing befalls to humankind and animals, live, death. So they think there is not superiority of mankind.
(20) All go to one place; all are from the dust, and all turn to dust again.
This verse continue to describe their opinion.
(21) Who knows whether the spirit of man goes upward, and the spirit of the beast goes downward to the earth?
Ibn Ezra והענין מי ומי שידע בבני האדם ההפרש שיש בין רוח האדם ורוח הבהמה והענין כי לא ימצא אחד מני אלף ודעת הרוח עמוקה וצריכה לראיו' ולא יוכלו להבין אפילו קצתם כי אם המשכילים שהתבררה מחשבתם במאזני החכמה ובארבעה יסודותיה שהשלשה מהם ספר וספר וספור ומורכב מן השנים ומתורת אלהינו יוכל להבין כי הנה אמר במיני הצמחים תדשא הארץ והנה יש לארץ כח להדשיא בדבר אלהים ובעבור היות המדשיא גוף ממנו יצאו ואליו ישובו ולא יעמוד הנולד שהולידה הארץ כי אם ימים קצובים בעבור שיש קץ לגדולו ובעמדו ולא יגדל ישוב לאחור וכן אמר ישרצו המים נפש והנה המים הולידו נפש כל ארץ ועוף ודג בדבר אלהים וכן אמר תוצא הארץ נפש חיה למינה ולא אמר בתורה נפש אדם רק אמר נעשה אדם בצלמנו כדמותינו **והזכיר שברא גופו מן האדמה ואחר כך ויפח באפיו נשמת חיים ורמז חיים בעבור שהיא עומדת ולא תאבד כנפש הבהמה והפרש יש בין נשמה ונפש כי לא מצאנו בכל המקרא נשמה כי עם על בני אדם כענין נותן נשמה לעם עליה וכל אשר נשמת רוח חיים באפיו שב על האדם לבדו ואמר שלמה בסוף הספר שרוח בני האדם תשוב אל האלהים ולא אל העפר
The verse says (note: by a rethorical question) that they are very rare among men, people who know... in Tora, it is mentioned that G-d created his (the man) body from the ground and in a next step He breathed in his nose a soul of life. The qualifier "of life" refers to the durability of the soul. She is not perishable as the the animal soul. There is a difference between NESHAMA and NEFESH. Whe do find the word NESHAMA in Bible only for humankind...
(22) So I saw that there is nothing better, than that a man should rejoice in his work; for that is his portion; who can bring him see what shall be after him?
Ibn Ezra. כי אלה החושבים שהם כמו הבהמות אין טוב להם מאשר ישמחו בחייהם כי אין להם חלק אחר ולמה יתעסקו בדברים יעזבום אחריהם
I saw: Because for those who think they are equivalent to animals, there is nothing better in them, than enjoing life, because they have no part to something else. What's the point to bustle for things they will lose after life.