diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index e2f92aae08..43dab5c083 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -64,6 +64,7 @@
 #include "rewrite/rewriteManip.h"
 #include "storage/dsm_impl.h"
 #include "utils/lsyscache.h"
+#include "utils/partcache.h"
 #include "utils/rel.h"
 #include "utils/selfuncs.h"
 #include "utils/syscache.h"
@@ -7527,7 +7528,17 @@ IsRelParallelModeSafeForModify(Oid relid)
 	if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
 	{
 		int i;
-		PartitionDesc pd = RelationGetPartitionDesc(rel);
+		PartitionDesc pd;
+
+		PartitionKey key = RelationGetPartitionKey(rel);
+
+		if (func_parallel(key->partsupfunc->fn_oid) != PROPARALLEL_SAFE)
+		{
+			table_close(rel, lockmode);
+			return false;
+		}
+
+		pd = RelationGetPartitionDesc(rel);
 		for (i = 0; i < pd->nparts; i++)
 		{
 			if (!IsRelParallelModeSafeForModify(pd->oids[i]))
