Skip to content

Functions: generate date and time functions #4107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions scripts/settings/autogenerate-settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ if [ -f "$FUNCTION_SQL_FILE" ]; then
"Comparison"
"Conditional"
"Distance"
"Dates and Times"
)

for CATEGORY in "${FUNCTION_CATEGORIES[@]}"; do
Expand All @@ -271,15 +272,17 @@ if [ -f "$FUNCTION_SQL_FILE" ]; then
}

# Rename the temporary output file to the correct name
CATEGORY_LOWER=$(echo "$CATEGORY" | tr '[:upper:]' '[:lower:]')
# Category can be "Dates and Times" for example, resulting in `dates and times-functions.md` so we change spaces to underscores
CATEGORY_LOWER=$(echo "$CATEGORY" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
if [ -f "temp-functions.md" ]; then
echo "${CATEGORY_LOWER}-functions.md"
mv "temp-functions.md" "${CATEGORY_LOWER}-functions.md" || {
echo "[$SCRIPT_NAME] Error: Failed to rename temp-functions.md to ${CATEGORY_LOWER}-functions.md"
exit 1
}
echo "[$SCRIPT_NAME] Generated ${CATEGORY_LOWER}-functions.md"
else
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found after processing $CATEGORY functions"
echo "[$SCRIPT_NAME] Warning: temp-functions.md not found for $CATEGORY"
fi
done
else
Expand Down Expand Up @@ -360,7 +363,9 @@ insert_src_files=(
"comparison-functions.md"
"conditional-functions.md"
"distance-functions.md"
"dates_and_times-functions.md"
)

insert_dest_files=(
"docs/about-us/beta-and-experimental-features.md"
"docs/sql-reference/functions/arithmetic-functions.md"
Expand All @@ -370,8 +375,10 @@ insert_dest_files=(
"docs/sql-reference/functions/comparison-functions.md"
"docs/sql-reference/functions/conditional-functions.md"
"docs/sql-reference/functions/distance-functions.md"
"docs/sql-reference/functions/date-time-functions.md"
)
echo "[$SCRIPT_NAME] Inserting generated markdown content between <!-- AUTOGENERATED_START --> <!-- AUTOGENERATED_END --> tags"

echo "[$SCRIPT_NAME] Inserting generated markdown content between AUTOGENERATED_START and AUTOGENERATED_END tags"
for i in "${!insert_src_files[@]}"; do
src_file="${insert_src_files[i]}"

Expand Down Expand Up @@ -405,7 +412,7 @@ for i in "${!insert_src_files[@]}"; do
# Replace the original file with the modified content
mv "$tmp_file" "$dest_full_path"
else
echo "[$SCRIPT_NAME] Error: Expected to find <!--AUTOGENERATED_START--> and <!--AUTOGENERATED_END--> tags in $dest_full_path, but did not"
echo "[$SCRIPT_NAME] Error: Expected to find AUTOGENERATED_START and AUTOGENERATED_END tags in $dest_full_path, but did not"
exit 1
fi

Expand All @@ -424,7 +431,7 @@ cd "$parent_of_tmp" || echo "[$SCRIPT_NAME] Warning: Failed to cd back to parent
echo "[$SCRIPT_NAME] Removing contents of temporary directory: $tmp_dir"
# Use full path for removal just in case cd failed
rm -rf "$tmp_dir"/*
rmdir "$tmp_dir" 2>/dev/null || echo "[$SCRIPT_NAME] Info: Did not remove $tmp_dir (might contain hidden files or already gone)."
rmdir "$tmp_dir" 2>/dev/null || echo "[$SCRIPT_NAME] Unable to remove $tmp_dir"

echo "[$SCRIPT_NAME] Auto-generation of settings markdown pages completed successfully."
exit 0
Loading